[go: up one dir, main page]

0% found this document useful (0 votes)
17 views6 pages

DB Lecture 2

The document discusses data abstraction in database systems, outlining the physical, logical, and view levels of abstraction that help users interact with data without needing to understand its complexities. It also introduces the ANSI-SPARC architecture, emphasizing user flexibility in data representation and independence from physical storage details. Additionally, it covers various data models, including hierarchical, network, object, ER, and relational models, along with database languages and integrity constraints.

Uploaded by

hodawbas123456
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views6 pages

DB Lecture 2

The document discusses data abstraction in database systems, outlining the physical, logical, and view levels of abstraction that help users interact with data without needing to understand its complexities. It also introduces the ANSI-SPARC architecture, emphasizing user flexibility in data representation and independence from physical storage details. Additionally, it covers various data models, including hierarchical, network, object, ER, and relational models, along with database languages and integrity constraints.

Uploaded by

hodawbas123456
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

‫‪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 ‫النب‬
‫عل ي‬ ‫صل ي‬
‫ي‬

You might also like