Professional Documents
Culture Documents
Relational Databases
Relational Databases
Dr Shazia A Afzal
History of Relational Databases
• 1970’s – E.F. Codd published an important paper on relational databases
• Two major prototypes were created
• Ingres by UC Berkeley
• System R by IBM
• Ingres used a query language QUEL that led to the creation of systems Ingres Corp
and SQL server, etc.
• R used SEQUEL and led to the development of DB2, Oracle, etc.
• In 1970’s, RDBMS became a recognised term and P. Chen proposed ER
model
• In 1980’s, SQL became the standard query language of relational database
systems
Copyright @ 2016, Pearson Education, Inc.
ER Modelling – Analysis Stage
System System
user Inappropriate output
entities
Appropriate
entities
• Weak entity
• dependent on a strong entity (identifying owner)…cannot exist
on its own
• does not have a unique identifier (only a partial identifier)
• entity box and partial identifier have double lines
• Identifying relationship
• links strong entities to weak entities
• Shown by solid line or by double line (depending on the tool)
Copyright @ 2016, Pearson Education, Inc.
Guidelines for Naming and Defining Entities
• Names:
• Singular noun
• Specific to organization
• Concise, or abbreviation
• For event entities, the
result not the process
• Name consistent for all
diagrams
• Attribute–property or characteristic of an
entity or relationship type
• Classifications of attributes:
• Required versus Optional Attributes
• Simple versus Composite Attribute
• Single-Valued versus Multivalued Attribute
• Stored versus Derived Attributes
• Identifier Attributes
a) Relationship
type (Completes)
b) Relationship
instances
Entities of
One entity two different
related to types related Entities of three
another of to each other different types
the same
related to each
entity type
other
Copyright @ 2016, Pearson Education, Inc.
Cardinality of Relationships
• One-to-One
• Each entity in the relationship will have exactly one related
entity
• One-to-Many
• An entity on one side of the relationship can have many
related entities, but an entity on the other side will have a
maximum of one related entity
• Many-to-Many
• Entities on both sides of the relationship can have many
related entities on the other side
c) Ternary relationship
a) Mandatory cardinalities
A patient must
A patient history is have recorded
recorded for one at least one
history, and can
and only one
patient have many
EER
notation
Only applies to
manufactured parts
Primary Key
Foreign Key
(implements 1:N relationship
between customer and order)
(a)
(b)
Foreign key
Foreign key
Copyright @ 2016, Pearson Education, Inc.
Example of mapping an M:N relationship
a) Completes relationship (M:N) b) Three resulting relations
Often in 1:1 relationships, Foreign key goes in the relation on the optional side,
one direction is optional matching the primary key on the mandatory side
a) An associative entity
(a) EMPLOYEE
entity with unary
relationship
(b)
EMPLOYEE
relation with
recursive
foreign key
(a) Bill-of-materials
relationships (unary M:N)
Getting it into
Third Normal
Form