03 DB Modeling Using ERD
03 DB Modeling Using ERD
03 DB Modeling Using ERD
Model
Muhammad Qasim
Design Stages
Choose DBMS
Implement System
Test System
Operational Maintenance
Sli
de
Database Design Stages
1) Analyze user Requirements
◦ Database designers interview prospective database users to
understand and document data requirements
Database Design Stages
2) Conceptual Data Model: A Conceptual Data Model is an organized view
of database concepts and their relationships. The purpose of creating a
conceptual data model is to establish entities, their attributes, and
relationships. In this data modeling level, there is hardly any detail available
on the actual database structure. Business stakeholders and data architects
typically create a conceptual data model.
Weak Entity:
A weak entity is dependent on a strong entity to ensure its existence. Unlike
a strong entity, a weak entity does not have any primary key. It instead has a
partial discriminator key. A weak entity is represented by a double rectangle.
The relation between one strong and one weak entity is represented by a
double diamond. This relationship is also known as identifying relationship.
ER Model - Basic Concepts
Attributes: 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. Attributes are represented by means of ellipses.
Every ellipse represents one attribute and is directly connected
to its entity (rectangle).
EMPLOYEE address
Candidate Key
Primary Key
Alternate Key
Foreign Key
Compound Key
Composite Key
Surrogate Key
Super Key: A super key is a group of single or multiple keys which
identifies rows in a table. A Super key may have additional attributes
that are not needed for unique identification.
In the above-given example, EmpSSN and EmpNum name are
superkeys.
CANDIDATE KEY in SQL is a set of attributes that uniquely identify tuples in a table.
Candidate Key is a super key with no repeated attributes. The Primary key should be
selected from the candidate keys. Every table must have at least a single candidate key. A
table can have multiple candidate keys but only a single primary key.
Properties of Candidate key:
It must contain unique values
Candidate key in SQL may have multiple attributes
Must not contain null values
It should contain minimum fields to ensure uniqueness
Uniquely identify each record in a table
Candidate key Example: In the given table Stud ID, Roll No, and email are candidate keys which help us
to uniquely identify the student record in the table.
PRIMARY KEY in DBMS is a column or group of columns in a table that uniquely
identify every row in that table. The Primary Key can’t be a duplicate meaning
the same value can’t appear more than once in the table. A table cannot have
more than one primary key.
Rules for defining Primary key:
Two rows can’t have the same primary key value
The value in a primary key column can never be modified or updated if any
Binary = degree 2
Ternary = degree 3
n-ary = degree
Mapping Cardinalities
Cardinality defines the number of entities in one entity set,
which can be associated with the number of entities of other
set via relationship set.
One-to-one − One entity from entity set A can be associated