+
Dr. Ramadan Babers
Faculty of Science - Helwan University
Fall-2018
D B
PDCA Life Cycle (for your information)
2
+
Relational Model
3
Relational Model History
4
 Introduced by Ted Codd in 1970 in a classic
paper
 Ted Codd was an IBM Researcher
 Many database concepts & products based on
this model
Relational Database
5
Relation In RDB
Supplier
S# SNAME STATUS CITY
S1
S2
S3
S4
S5
Smith 20 London
Jones 10 Paris
Black 30 Paris
Clark 20 London
Adams 30 Athens
Table name
Attribute
Table
Heading
Tuple
(Row)
Data value Relation
Cardinality
Relation Degree
Definition Summary
6
Informal Terms Formal Terms
Table Relation
Column Header Attribute
All possible Column Values Domain
Row Tuple
Table Definition Schema of a Relation
Populated Table State of the Relation
Relation Example
7
Characteristics of Relations
8
 tuples have no particular order
 ordering of attributes not important
 all values belonging to a particular
attribute are from the same domain
 attributes are atomic (undividable)
 attributes may have a null value
+
DBMS Architecture
9
Architecture
10
 DBMS can be seen as either single tier or multi-tier.
Database (Data) Tier: At this tier,
the database resides along with its query
processing languages. Relations, data and
their constraints exist at this level.
Application (Middle) Tier: sits in
the middle and acts as a mediator
between the end-user and the database.
User (Presentation) Tier: multiple
views of the database can be provided by
the application.All views are generated by
applications that reside in the application
tier.
Data Models
11
 Data models
 Define how the logical structure of a database is modeled.
 Are fundamental entities to introduce abstraction in a
DBMS.
 Define how data is connected to each other
(Relationships) and how they are processed and stored
inside the system.
The first data model could be flat data-models, where all the
data used are to be kept in the same plane and contain lots of
duplication and update anomalies.
Entity-Relationship Model (ER Model)
12
 ER Model contains:
1) Entity set,
2) Relationship set,
3) General attributes, and
4) Constraints.
Entity
Attributes
Entity-Relationship Model (ER Model)
13
1) Entity
 An entity can be a real-world object. For
example, in a school database, students,
teachers, classes, and courses offered can
be considered as entities.
 All these entities have some attributes or
properties that give them their identity.
 An entity set is a collection of similar
types of entities.
Entity-Relationship Model (ER Model)
14
2) Attribute
 Entities are represented by means of their
properties called attributes. All attributes have
values. For example, a student entity may have
name, class, and age as attributes.
Entity-Relationship Model (ER Model)
15
 There exists a domain or range of values that can
be assigned to attributes. For example, a student's
name cannot be a numeric value. It has to be
alphabetic. A student's age cannot be negative, etc.
Entity-Relationship Model (ER Model)
16
Types of Attributes
Simple attributes:
are atomic values. For example, a
student's phone number is an
atomic value of 10 digits.
Composite attribute:
are made of more than one
simple attribute. For example, a
student's complete name may
have first_name and last_name.
Entity-Relationship Model (ER Model)
17
Types of Attributes
Multivalued: attributes
are depicted by double ellipse.
Derived attribute:
are the attributes that do not
exist in the physical database,
but their values are derived
from other attributes present
in the database. For example,
average_salary and age.
Entity-Relationship Model (ER Model)
18
Entity-Set and Keys
Key is an attribute or collection of attributes that uniquely
identifies an entity among entity set.
For example, the ID_number of a student makes him/her
identifiable among students.
Keys Types
 Super Key: A set of attributes (one or more) that collectively
identifies an entity in an entity set.
 Candidate Key: A minimal super key is called a candidate key.
An entity set may have more than one candidate key.
 Primary Key: A primary key is one of the candidate keys
chosen by the database designer to uniquely identify the entity set.
Entity-Relationship Model (ER Model)
19
3) Relationship
 The relationship is the association among entities.
For example, an employee works_at a
department, a student enrolls in a course. Here,
Works_at and Enrolls are called relationships.
Employee Departmrnt
Student Course
Works at
enrolls
Entity-Relationship Model (ER Model)
20
Degree of Relationship
(also known as cardinality) is
the number of occurrences in
one entity which are associated
(or linked) to the number of
occurrences in another.
Entity-Relationship Model (ER Model)
21
Degree of Relationship
One-to-one: One entity from entity set A can be
associated with at most one entity of entity set B and
vice versa.
Entity-Relationship Model (ER Model)
22
Degree of Relationship
One-to-many: One entity from entity set A can be
associated with more than one entities of entity set
B, however an entity from entity set B can be
associated with at most one entity.
Entity-Relationship Model (ER Model)
23
Degree of Relationship
Many-to-many: One entity from A can be associated
with more than one entity from B and vice versa.

Db lec 02_new

  • 1.
    + Dr. Ramadan Babers Facultyof Science - Helwan University Fall-2018 D B
  • 2.
    PDCA Life Cycle(for your information) 2
  • 3.
  • 4.
    Relational Model History 4 Introduced by Ted Codd in 1970 in a classic paper  Ted Codd was an IBM Researcher  Many database concepts & products based on this model
  • 5.
    Relational Database 5 Relation InRDB Supplier S# SNAME STATUS CITY S1 S2 S3 S4 S5 Smith 20 London Jones 10 Paris Black 30 Paris Clark 20 London Adams 30 Athens Table name Attribute Table Heading Tuple (Row) Data value Relation Cardinality Relation Degree
  • 6.
    Definition Summary 6 Informal TermsFormal Terms Table Relation Column Header Attribute All possible Column Values Domain Row Tuple Table Definition Schema of a Relation Populated Table State of the Relation
  • 7.
  • 8.
    Characteristics of Relations 8 tuples have no particular order  ordering of attributes not important  all values belonging to a particular attribute are from the same domain  attributes are atomic (undividable)  attributes may have a null value
  • 9.
  • 10.
    Architecture 10  DBMS canbe seen as either single tier or multi-tier. Database (Data) Tier: At this tier, the database resides along with its query processing languages. Relations, data and their constraints exist at this level. Application (Middle) Tier: sits in the middle and acts as a mediator between the end-user and the database. User (Presentation) Tier: multiple views of the database can be provided by the application.All views are generated by applications that reside in the application tier.
  • 11.
    Data Models 11  Datamodels  Define how the logical structure of a database is modeled.  Are fundamental entities to introduce abstraction in a DBMS.  Define how data is connected to each other (Relationships) and how they are processed and stored inside the system. The first data model could be flat data-models, where all the data used are to be kept in the same plane and contain lots of duplication and update anomalies.
  • 12.
    Entity-Relationship Model (ERModel) 12  ER Model contains: 1) Entity set, 2) Relationship set, 3) General attributes, and 4) Constraints. Entity Attributes
  • 13.
    Entity-Relationship Model (ERModel) 13 1) Entity  An entity can be a real-world object. For example, in a school database, students, teachers, classes, and courses offered can be considered as entities.  All these entities have some attributes or properties that give them their identity.  An entity set is a collection of similar types of entities.
  • 14.
    Entity-Relationship Model (ERModel) 14 2) Attribute  Entities are represented by means of their properties called attributes. All attributes have values. For example, a student entity may have name, class, and age as attributes.
  • 15.
    Entity-Relationship Model (ERModel) 15  There exists a domain or range of values that can be assigned to attributes. For example, a student's name cannot be a numeric value. It has to be alphabetic. A student's age cannot be negative, etc.
  • 16.
    Entity-Relationship Model (ERModel) 16 Types of Attributes Simple attributes: are atomic values. For example, a student's phone number is an atomic value of 10 digits. Composite attribute: are made of more than one simple attribute. For example, a student's complete name may have first_name and last_name.
  • 17.
    Entity-Relationship Model (ERModel) 17 Types of Attributes Multivalued: attributes are depicted by double ellipse. Derived attribute: are the attributes that do not exist in the physical database, but their values are derived from other attributes present in the database. For example, average_salary and age.
  • 18.
    Entity-Relationship Model (ERModel) 18 Entity-Set and Keys Key is an attribute or collection of attributes that uniquely identifies an entity among entity set. For example, the ID_number of a student makes him/her identifiable among students. Keys Types  Super Key: A set of attributes (one or more) that collectively identifies an entity in an entity set.  Candidate Key: A minimal super key is called a candidate key. An entity set may have more than one candidate key.  Primary Key: A primary key is one of the candidate keys chosen by the database designer to uniquely identify the entity set.
  • 19.
    Entity-Relationship Model (ERModel) 19 3) Relationship  The relationship is the association among entities. For example, an employee works_at a department, a student enrolls in a course. Here, Works_at and Enrolls are called relationships. Employee Departmrnt Student Course Works at enrolls
  • 20.
    Entity-Relationship Model (ERModel) 20 Degree of Relationship (also known as cardinality) is the number of occurrences in one entity which are associated (or linked) to the number of occurrences in another.
  • 21.
    Entity-Relationship Model (ERModel) 21 Degree of Relationship One-to-one: One entity from entity set A can be associated with at most one entity of entity set B and vice versa.
  • 22.
    Entity-Relationship Model (ERModel) 22 Degree of Relationship One-to-many: One entity from entity set A can be associated with more than one entities of entity set B, however an entity from entity set B can be associated with at most one entity.
  • 23.
    Entity-Relationship Model (ERModel) 23 Degree of Relationship Many-to-many: One entity from A can be associated with more than one entity from B and vice versa.