Lecture 2
By: Muhammed Gamal Maklad
علَى آ ِل ُم َح َّمد،
علَى ُم َح َّم ٍد َو َ
علَى إِب َْراهِي َمَ ،وب َِاركْ َ
صلَّيْتَ َ
علَى آ ِل ُم َح َّمدٍَ ،ك َما َ
علَى ُم َح َّم ٍد َو َ اللَّ ُه َّم َ
ص ِ ِّل َ
علَى آ ِل ِإب َْراهِي َم ،فِي ا ْل َعالَمِ ينَ ِ ،إنَّكَ حَمِي ٌد َم ِجي ٌد. َك َما ب َ
َاركْتَ َ
❖ DATA ABSTRACTION:
➢ database system is a collection of interrelated data and a set of programs that allow users to access and
modify these data.
➢ A major purpose of a database system is to provide users with an abstract view of the data.
➢ the system hides certain details of how the data are stored and maintained.
➢ For the system to be usable, it must retrieve( )يستردdata efficiently.
➢ database-system users are not computer trained; So developers hide the complexity from users through
several levels of abstraction.
Physical level (or Internal View / Schema): The lowest level of abstraction describes how the data are
actually stored. The physical level describes complex low-level data structures in detail.
Logical level (or Conceptual View / Schema): describes what data are stored in
the database, and what relationships exist among those data. The logical level
thus describes the entire database in terms of a small number of relatively
simple structures.
View level (or External View / Schema): The highest level of abstraction
describes only part of the entire database. Even though the logical level uses
simpler structures, complexity remains because of the variety of information
stored in a large database.
وال يهتم بكيفية استخدام البيانات، و ده بيهتم كيفية تخزين البيانات على مستوى الجهازPhysical level
و ده بيهتم ب تحديد كيفية تنظيم البيانات والعالقات بينهاLogical level
المستوي ده بيحدد طريقة عرض البيانات لليوزر بشكل يخلي من لسهل علي المستخدم التعامل معاهاView level
❖ ANSI-SPARC ARCHITECTURE:
➢ Framework for DBS:
• ANSI: American National Standards Institute • SPARC: Standards Planning and Requirements Committee
➢ The Objectives of this architecture: الغرض منه ايه
• Each user should be able to change the way he or she views the data. كل يوزر بيختار الداتا تظهرله ازاي
• Users need not to know physical database storage details. اليوزر مش في حاجه انه يعرف تفاصسل الداتا بيز
• DBA able to change database storage structures without affecting the users’ views.
• DBA able to change conceptual structure of database without affecting all users.
❖ Logical data independence: Conceptual level changes shouldn’t affect
external levels.
❖ Physical data independence: Change to internal level shouldn’t affect
the conceptual level.
1
Muhammed Gamal Maklad النب
عل ي صل ي
ي
❖ INSTANCES AND SCHEMAS:
Database schema (intension) Database instance (extension)
Formal description of the structure of the database Data stored in a database at a particular time
(The overall design of the database)
Specified during the database design process
Does not change frequently Changes frequently
DATA MODEL
❖ Data model: a collection of concepts that can be used to describe the structure of a database at the physical,
logical, and view levels.
❖ Structure of a database mean the data types, relationships, and constraints that apply to the data
❖ Most data models also include a set of basic operations for specifying retrievals and updates on the database.
❖ TYPES OF DATA MODEL:
➢ HIERARCHICAL MODEL:
• was developed by IBM and North American Rockwell known as Information Management System.
• It represents the data in a hierarchical tree structure. So , data is sorted hierarchically
• This model is the first DBMS model.
واحد بسparents بيكون لهRecod بحيث كلtree بص ي هندسه هنا بيكون التمثيل علي شكل
➢ NETWORK DATABASE MODEL:
• Network Database Model is same like Hierarchical Model, but the only difference is that it allows a record
to have more than one parent
• It replaces the hierarchical tree with a graph.
• It represents the data as record types and one-to-many relationship.
• This model is easy to design and understand.
• In this model, there is no need of parent to child association like the hierarchical
model.
Record عادي بحيث العالقه بيكل كلparent ممكن يكون له أكتر منRecord هنا زي اللي فات بالظبط طب اومال فين الفرق و الفرق ان كل
one to Meny والتاني ممكن تكون
➢ OBJECT MODEL:
• stores the data in the form of objects, classes and inheritance.
• handles more complex applications, such as Geographic Information System (GIS), scientific experiments,
engineering design and manufacturing.
• It is used in File Management System.
• It represents real world objects, attributes and behaviors.
• It provides a clear modular structure, So It is easy to maintain and modify the existing code
2
Muhammed Gamal Maklad النب
عل ي صل ي
ي
ER Model Relational Model
Developed by Peter Chen in 1976.D Developed by E.F. Codd in 1970.
ER model is the high level or conceptual model. It is the representational or implementation model.
It is used by people who don't know how database is It is used by programmers.
implemented.
It represents collection of entities and describes It represents data in the form of tables and describes
relationship between them. relationship between them.
It consists of components like Entity, Entity Type, Entity It consists of components like domain, attributes, tuples.
Set.
It is easy to understand the relationship between entities. It is less easy to derive the relationship between different
is useful in developing a conceptual design for the tables.
database
It describes cardinality. It does not describe cardinality.
Some of the popular Language and Notations used: Some of the popular Language and Notations used:
• Chen • SQL
• UML
• MySQL
• Crow's foot
• Bachman and others.
هتالقي الداتا هنا متمثله في جداول
بحيث هتالقي فيColumn بيربط كل
جدول بالتاني
❖ DATABASE LANGUAGES AND INTERFACES:
➢ Data definition language (DDL): Defines both schemas.
➢ Data manipulation language (DML): Allows retrieval, insertion, deletion, modification.
❖ Database management systems (DBMS) :
DBMS في تلت انواع من التصنيف لل
بتستخدمMySQL وOracle بنالقي هنا ان أكبر الشركات زيData Model النوع األول من التصنيف احنا بنصنف علي أساس نوع •
Hierarchical , Network علي الرغم من كده لسه في ناس و شركات بتستخدم الموديل التقليديه اللي هوRelational model
Multiuser و في بيدعمSignal User بيدعمDBMS علشان فيUser Number النوع التاني علي أساس •
Distributed وCentralized و ده بينقسم لنوعينDatabase Distribution النوع التالت علي حسب •
3
Muhammed Gamal Maklad النب
عل ي صل ي
ي
❖ The Relational Data Model (RDM):
➢ relational data model describes the world as “a collection of interrelated relations (or tables).
➢ relation has a name that is distinct from all other relation names in the relational schema.
➢ Each cell of the relation contains exactly one atomic (single) value.له قيمه واحده
➢ Each attribute has a distinct name. كل خانه ليها اسم مميز او مش متكرر يعني
➢ The values of an attribute are all from the same domain.
➢ Each tuple is distinct; there are no duplicate tuples.
➢ The order of attributes has no significance.
➢ The order of tuples has no significance, theoretically. (However, in practice,
the order may affect the efficiency of accessing tuples.)
➢ A domain is the original sets of atomic values used to model data.
➢ atomic value, we mean that each value in the domain is indivisible as far as the relational model is concerned.
Cardinality و عدد الصفوف اسمهاRecord و القسم مثال كل صف في الجدول ده اسمهId بص ي هندسه لو عندنا جدول لتسجيل بيانات الطالب فيه االسم و
ده بيحدد القيم اللي مسموح ادخلها في خانه او الخليه فاهمتي يعنيdomain تمام لحد هنا طبDegree و عدد األعمدة اسمهاAttributes طب كل عمود اسمه
دي بتكون قيم مينفعش تتجزء علي أكتر من خانهAtomic Value بيكون محدد قيم لو مثال في الدوله يكون محدد اني اخل مصر او السعوديه مثال طب
➢ Super key : An attribute, or set of attributes, that uniquely identifies a tuple within a relation.
➢ Candidate key: A super key such that no proper subset is a super key within the relation.
➢uniqueness – in each tuple of R, the values of K uniquely identify that tuple;
➢irreducibility – no proper subset of K has the uniqueness property.
➢ composite key: when a key consists of more than one attribute.
➢ Primary key: The candidate key that is selected to identify tuples uniquely within the relation.
➢ Foreign key: An attribute, or set of attributes, within one relation that matches the candidate key of some
(possibly the same) relation
طب نختاره علي أساس ايه علي أساس ان الداتا اللي في كل خليه في العمود دهprimary key بص احنا بنختار عمود من الجدول نسميه
زي بعض و مينفعش برضه خليه تبقي فاضيه لما بنالقي عمودID كده تالقي مفيش اتنينID ميكونش متكرره في العمود يعني ايه يعني زي
Candidate key طب لو لقينا أكتر من عمود بينطبق عليه نفس المواصفات بنسميهمSuper Key بينطبق عليه كل المواصفات دي بنقول عليه
ده بيكون عمود موجود في جدول و أناForeign key و أنا بختار واحد طب ايه Primary Key يعني في أكتر من عمود مرشح انه يكون
باخده أحطه في جدول تاني علشان أربطهم ببعض بص علي المقارنه اللي في الصفحه اللي فاتت وأنت تفهم قصدي
❖ INTEGRITY CONSTRAINTS:
➢ Null: Represents a value for an attribute that is currently unknown or is not applicable for this tuple.خانه فاضيه
➢ To ensure entity integrity, it is required that every table have a primary key. Neither the PK nor any part of it
can contain null values. This is because null values for the primary key mean we cannot identify some rows
4
Muhammed Gamal Maklad النب
عل ي صل ي
ي
يعني مفيش أي قيمه فيه فاضيه او غير معلومهNull مفهوش أي قيمprimary key هنا يقصد اننا نتأكد ان
➢ Referential integrity requires that a foreign key must have a matching primary key or it must be null. This
constraint is specified between two tables (parent and child); it maintains the correspondence between rows in
these tables. It means the reference from a row in one table to another table must be valid.
ونحط قيمة5 ل1 بينprimary key بس مينفعش يبقي مثال قيمNull ممكن يبقيForeign key بص ي هندسه هنا يقصد ان قيم
أل مينفعش الزم تبقي في نفس الرينج6 بForeign key
➢ General constraints: Additional rules specified by the users or database administrators of a database that
define or constrain some aspect of the enterprise دي بتكون قواعد و قيود علي مستخدمين الداتا بيز.
➢ Domain Integrity: Domain restricts the values of attributes in the relation and is a constraint of the relational
model.
❖ NULL VALUE:
➢ null is a special symbol, independent of data type, which means either unknown or inapplicable. It does not
mean zero or blank.
➢ No data entry, Not permitted in the primary key , Should be avoided in other attributes
دي بتكون اما القيمه غير معروفه أو الخليه فاضيهNull زي ما قولنا
The result of a comparison operation is null when either argument is null. The result of an arithmetic operation is
null when either argument is null (except functions that ignore nulls).
❖ VIEWS:
➢ Base relation: A named relation corresponding to an entity in the conceptual schema, whose tuples are
physically stored in the database.
➢ View: The dynamic result of one or more relational operations operating on the base relations to produce
another relation. A view is a virtual relation that does not necessarily exist in the database but can be produced
upon request by a particular user, at the time of request.
،علَى آ ِل ُم َح َّمد
َ علَى ُم َح َّم ٍد َو
َ ْ َوب َِارك،علَى إِب َْراهِي َم
َ َصلَّيْت
َ َك َما،ٍعلَى آ ِل ُم َح َّمد
َ علَى ُم َح َّم ٍد َو َ اللَّ ُه َّم
َ ص ِ ِّل
ِإنَّكَ حَمِي ٌد َم ِجي ٌد، َ فِي ا ْلعَالَمِ ين،علَى آ ِل ِإب َْراهِي َم َ َك َما ب
َ ََاركْت
5
Muhammed Gamal Maklad النب
عل ي صل ي
ي