Week 04
Week 04
Week 04
SYSTEMS
Week-4
WHAT IS GOOD DATABASE DESIGN?
4
• Turn information items into columns
5
• Specify primary keys
6
• Set up the table relationships
7
• Refine your design
8
• Apply the normalization rules
IF YOU DON’T FOLLOW DESIGN/
MODEL THEN …
DESIGN PROCESS
CONCEPTUAL MODEL
Model: an abstraction of a real-world object
or event
Useful in understanding complexities of the
real-world environment
Data model
A diagram that displays a set of tables and the
relationships between them
WHAT IS AN ENTITY RELATIONSHIP
DIAGRAM (ERD)?
ER model is used to show the Conceptual
schema of an organization.
8
E-R Model…
9
Why use ER Diagrams?
10
Advantages
11
Disadvantages
12
SUMMARY OF ER-DIAGRAM NOTATION
Symbol Meaning
ENTITY TYPE
RELATIONSHIP TYPE
ATTRIBUTE
KEY ATTRIBUTE
MULTIVALUED ATTRIBUTE
COMPOSITE ATTRIBUTE
DERIVED ATTRIBUTE
E1 R E2 TOTAL PARTICIPATION OF E2 IN R
E1 N
R E2 CARDINALITY RATIO 1:N FOR E1:E2 IN R
(min,max)
R E STRUCTURAL CONSTRAINT (min, max) ON PARTICIPATION OF E IN R
14
Components of the ER Diagram
• Entities.
• Attributes.
• Relationships.
Example
15
What is an Entity?
• Strong Entity
− Strong entity is an entity which has a key attribute.
− The primary key helps in identifying each entity uniquely.
− e.g., Faysal Bank is uniquely identified by its bank number.
• Weak Entity
− A weak entity cannot be uniquely identified by its own attributes.
− Weak entity types have partial keys.
− Partial Keys are set of attributes with the help of which the tuples of the weak entities
can be distinguished and identified.
− They are represented with double rectangles.
18
No Unique key
Partial Key/Discriminator 19
Partial Key
Weak Entity
Identifying
Relationship
What is an attribute?
21
GUIDELINES FOR NAMING ATTRIBUTES
1. Simple attribute.
2. Composite attribute.
3. Single valued attribute.
4. Multi valued attribute.
5. Derived attribute.
6. Key attribute.
23
1. Simple attribute
Example:
CNIC
Here, student’s class, gender, dob are atomic values which can not be
divided further.
24
2. Composite attribute
― A composite attribute is made up of more than one
simple attribute.
― A composite attribute can be further divisible.
Example:
Here, the attributes “Name” and “Address” are composite attributes as they are composed of
many other simple attributes.
25
3. Single Valued Attribute:
― These are the attributes which can take only one
value at a time.
Example:
Here, all the attributes are single valued attributes as they can take
only one at a time.
26
4. Multi-Valued Attribute
―These are the attributes which can take more
than one value at a time.
― It is represented by a double ellipse.
Example:
Here, the attribute “roll_no” is a key attribute as it can identify each student
uniquely.
29
7. Descriptive Attribute
―The descriptive attribute describes a relationship. It
gives additional information about the relationship.
―
Example:
Practice Question
Composite Attribute
Key Attribute
Relationship
Entity
Entity
Derived
Multi-valued Attributes Descriptive
Attribute
Attributes
s
CASE STUDY
A university registrar’s office maintains data about the following
entities:
1. courses, including number, title, credits, syllabus, and
prerequisites;
2. course offerings, including course number, year, semester, section
number, instructor(s), timings, and classroom;
3. students, including student-id, name, and program; and
4. instructors, including identification number, name, department, and
title. Further, the enrollment of students in courses and grades
awarded to students in each course they are enrolled for must be
appropriately modeled.