Chap5of SDBMS
Chap5of SDBMS
Chap5of SDBMS
•Contents
• Basic concepts: entities and entity types, attributes and keys, relationships and relationship
types
• Entity-Relationship schema (ER diagram)
• Constraints on relationship types
• Design choices
• Enhanced Entity-Relationship model features
• Steps in designing an ER schema
• Translation of an ER schema to tables
Cont…
orders
SUPPLIERS Chain
SName SAddress
• Limit the number of possible combinations of entities that may participate in a relationship set.
There are two types of constraints: cardinality ratio and participation constraints
• Very useful concept in describing binary relationship types. For binary relationships, the
cardinality ratio must be one of the following types:
• Many-To-Many ( default )
EMPLOYEES DEPARTMENTS
• Meaning: An employee can work in many departments (≥ 0) , and a department can have several
employees
Cont…
• Many-To-One
EMPLOYEES DEPARTMENTS
• Meaning: An employee can work in at most one department (≤ 1), and a department can have
several employees.
• One-To-Many
EMPLOYEES DEPARTMENTS
• Meaning: An employee can work in many departments (≥ 0) , but a department can have at most
one employee.
• One-To-One
EMPLOYEES DEPARTMENTS
• Meaning: An employee can work in at most one department, and a department can have at most
one employee.
Cont…
• Steps in Designing an Entity-Relationship Schema
• Step 1: Identify entity types (entity type vs. attribute)
• Step 2: Identify relationship types
• Step 3: Identify and associate attributes with entity and relationship types
• Step 4: Determine attribute domains
• Step 5: Determine primary key attributes for entity types
• Step 6: Associate (refined) cardinality ratio(s) with relationship types
• Step 7: Design generalization/specialization hierarchies including constraints
(includes natural language statements as well)
Cont…
In SQL:
create table Customers(
FName char(40),
LName char(40),
CAddress char(70),
Account real
);
A row in such a table corresponds to an entity from the entity set.
Logical Data Model: The Relational Model