Professional Documents
Culture Documents
SYSTEMS
Unit-2
Engineered for Tomorrow
Presented by
CSE, MVJCE
Engineered for Tomorrow
Database Design
Conceptual design: (ER Model is used at this stage.)
What are the entities and relationships in the enterprise?
What information about these entities and relationships should we
store in the database?
What are the integrity constraints or business rules that hold?
A database `schema’ in the ER Model can be represented
pictorially (ER diagrams).
Can map an ER diagram into a relational schema.
Engineered for Tomorrow
Modeling
A database can be modeled as:
a collection of entities,
relationship among entities.
An entity is an object that exists and is distinguishable from other
objects.
Example: specific person, company, event, plant
Entities have attributes
Example: people have names and addresses
An entity set is a set of entities of the same type that share the
same properties.
Example: set of all persons, companies, trees, holidays
3
Engineered for Tomorrow
Attributes
An entity is represented by a set of attributes, that is descriptive properties
possessed by all members of an entity set.
Derived attributes
Can be computed from other attributes
4
Engineered for Tomorrow
5
Engineered for Tomorrow
Mapping Cardinalities
6
Engineered for Tomorrow
Mapping Cardinalities
7
Engineered for Tomorrow
ER Model Basics
name
ssn lot
Employees
8
Engineered for Tomorrow
name
ER Model Basics (Contd.) ssn lot
since
name dname
ssn lot did budget Employees
super- subord
Employees Works_In Departments visor inate
Reports_To
9
Engineered for Tomorrow
Relationship Sets
A relationship is an association among several entities
10
Engineered for Tomorrow
Relationships between more than two entity sets are rare. Most
relationships are binary.
12
Engineered for Tomorrow
since
name dname
Additional features of
ssn lot did
the ER model
Consider Works_In: An
employee can work in
many departments; a dept
can have many employees.
In contrast, each dept has at
most one manager,
according to the key
constraint on Manages.
1-to-1 1-to Many Many-to-1 Many-to-Many
13
Engineered for Tomorrow
Participation Constraints
Does every department have a manager?
If so, this is a participation constraint: the participation of
Departments in Manages is said to be total (vs. partial).
Every Departments entity must appear in an instance of the
Manages relationship.
since
name dname
ssn lot did budget
Works_In
since
14
Engineered for Tomorrow
Weak Entities
A weak entity can be identified uniquely only by considering the primary
key of another (owner) entity.
Owner entity set and weak entity set must participate in a one-to-many
relationship set (one owner, many weak entities).
Weak entity set must have total participation in this identifying
relationship set.
name
cost pname age
ssn lot
15
Engineered for Tomorrow
16
Engineered for Tomorrow
17
Engineered for Tomorrow
Aggregation ssn
name
lot
Used when we have to
model a relationship
Employees
involving (entitity sets and)
a relationship set.
Aggregation allows us Monitors until
to treat a relationship set
as an entity set for
purposes of participation started_on since
dname
in (other) relationships. pid pbudget did
budget
18
Engineered for Tomorrow
Aggregation
Consider the ternary relationship works_on, which we saw earlier
Suppose we want to record managers for tasks performed by an
employee at a branch
19
Engineered for Tomorrow
Aggregation (Cont.)
Relationship sets works_on and manages represent overlapping
information
Every manages relationship corresponds to a works_on relationship
However, some works_on relationships may not correspond to any
manages relationships
So we can’t discard the works_on relationship
20
Engineered for Tomorrow
21
Engineered for Tomorrow
policyid cost 22
Engineered for Tomorrow
23
Engineered for Tomorrow
24
Engineered for Tomorrow
Summary of ER (Contd.)
Several kinds of integrity constraints can be expressed in the ER model: key
constraints, participation constraints, and overlap/covering constraints for
ISA hierarchies. Some foreign key constraints are also implicit in the
definition of a relationship set.
Some constraints (notably, functional dependencies) cannot be expressed
in the ER model.
Constraints play an important role in determining the best database
design for an enterprise.
25
Engineered for Tomorrow
Summary of ER (Contd.)
ER design is subjective. There are often many ways to model a given
scenario. Analyzing alternatives can be tricky, especially for a large
enterprise. Common choices include:
Entity vs. attribute, entity vs. relationship, binary or n-ary
relationship, whether or not to use ISA hierarchies, and whether or
not to use aggregation.
Ensuring good database design: resulting relational schema should be
analyzed and refined further. FD information and normalization
techniques are especially useful.
26
Engineered for Tomorrow
Example
Assume we have the following application that models cricket teams, capture the
following information in the ER- Diagram
We have a set of teams, each team has an ID, name, stadium, and to which country
this team belongs.
Each team has many players, and each player belongs to one team. Each player has a
number, name, DoB, start year, and jersey number that he uses.
Teams play matches, in each match there is a host team and a guest team. The match
takes place in the stadium of the host team.
For each match we need to keep track of the following:
The date on which the match is played
The final result of the match
The players participated in the match. For each player, how many runs he scored,
whether or not he took wickets, and whether or not he scored 100’s.
Each match has exactly three umpires. For each umpire we have an ID, name, DoB,
years of experience. Two umpires are main and the other one is the third umpire.
27
ID
DOB ExpYears
UMPIRE Name
Is Main
Name
ID
role
Country Host
Date
TEAM
Score
Stadium
MATCHES
Guest
Guest Score
Host Score
Belongs_to
In_match
MATCH- Runs
Plays
PLAYER
P_Num PLAYER Wickets
P_Name 100’s
Dob Start_Year
Jersey_No
28
Example
Company stores information on its shipped item. The requirements are as
follows
Shipped items can be characterized by item number (unique), weight,
insurance amount, destination and delivery date. Shipped items are received
at a single trade center.
Trade centers are characterized by their type, ID, and address. Shipped
items are dispatched via one or more standard transportation.
These transportation are characterized by a unique schedule Number, mode
(e.g, airways, waterways, roadways), and a delivery Route.
Create an E-R diagram that captures this information.
29
Item_No
Weight
InsurancAmt Waterways
Shipped Items
N
Airways
Destination
N Roadways
Via
DeliverDate
Mode
Received
From
N
Transportation
ScheduleNo
1
City
Address
Type
Country
Street
30