You are on page 1of 23

C O N C E P T U A L D ATA M O D E L L I N G

USING THE
E N T I T Y- R E L A T I O N S H I P M O D E L

1st Sem, MSc.

SSS Shameem Apr-2022 Database Management, MSc., DOC


CONTENT
❑ Conceptual Data Modelling
• Basic Concepts of Data Modelling,
• Design Issues,
• Mapping Constraints,
• Structure of Relational Databases
• Database Schema, Keys
• E-R diagram,
• Weak Entity Types,
• Design of E-R Database Schema,

• Reduction to Relational Schemas.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
• Keys play important role in relational database.
• Used to uniquely identify any record or row of data from the table.
• Also used to establish and identify relationships between tables.
• Example, ID is used as key in Student table because it is unique for each student.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Primary key
• used to identify one and only one instance of an entity uniquely.
• An entity can contain multiple keys.
• The key which is most suitable from those lists becomes a primary key.
• Example, ID can be primary key since it is unique for each employee.
• SSN, License_Number and Passport_Number can also be considered primary keys since they are also unique.
• primary key selection is based on requirements.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Candidate key
• An attribute or set of attributes that can uniquely identify a tuple/record.
• Except for primary key, the remaining attributes are considered a candidate key.
• candidate keys are as strong as primary key.
• Example, ID is best suited for primary key.
• Rest of the attributes, (SSN, Passport_Number, License_Number etc.) are considered a candidate key

• Super key is an attribute set that can uniquely identify a tuple.


• A super key is a superset of a candidate key

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Alternate key
• One/more attributes (or combination of attributes) may uniquely identify tuple in relation → candidate keys.
• One key is chosen as primary key from these candidate keys.
• Remaining candidate key (if it exists) is termed alternate key.
• alternate keys = candidate keys - primary key.
• alternate key may or may not exist.
• If there is only one candidate key in a relation = primary key; it does not have an alternate key)
• Composite key is a candidate key with minimum two/more attributes.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Foreign key
• Used to link/associate two tables.
• Used to point to the primary key of another table.
• Example, In DEPARTMENT table Department_Id is primary key, and in EMPLOYEE table Employee_ID is
primary key.
• Both tables are related by making Department_Id as foreign key in EMPLOYEE table.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Artificial key
• created using arbitrarily assigned data.
• These keys are created when primary key is large and complex and has no relationship with many other
relations.
• data values of artificial keys are usually numbered in serial order (autonumber).
• Example, primary key (composed of Emp_ID, Emp_role, and Proj_ID), is large. So it would be better to add
a new virtual attribute to identify each tuple in the relation uniquely.

Fruits
Row_Id
Name
Price
Season

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
• ER model stands for an Entity-Relationship model.
• High-level data model.
• used to define the data elements and relationship for a specified system.
• develops a conceptual design for database.
• develops a very simple and easy to design view of data.
• database structure is portrayed as a diagram called an entity-relationship (E-R) diagram.
• Example, school database.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Component of ER Diagram

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Component of ER Diagram

Entity, Entity Type, Entity Set –


• An object with physical existence (student, car, house, employee), or it object with
conceptual existence (company, job, university, loan).
• represented by a rectangle
• An Entity is an object of Entity Type.
• Set of all entities is called entity set.
• Example, E1 is an entity having Entity-Type Student and set of all students is the Entity-Set.
• An entity that depends on another entity called weak entity.
• Weak entity is represented by a double rectangle.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Component of ER Diagram

Attribute –

• Describes the property of an entity.


• Eclipse is used to represent an attribute.
• Example, id, age, contact number, name, etc. can be attributes of a student.
• Key attribute: represent main characteristics of an entity.
• It represents a primary key (uniquely identifies the entity).
• Represented by an ellipse with the text underlined.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Component of ER Diagram

Attribute –

• Composite attribute is composed of many other attributes.

• Multivalued attribute can have more than one value (double oval).

• Derived attribute is derived from other attribute (dashed ellipse).

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Component of ER Diagram

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Component of ER Diagram

Relationship –

• Describes the relation/association between entities.


• Diamond or rhombus is used to represent the relationship.

Degree of a relationship set: number of different entity sets participating in a relationship.


• Unary Relationship – only ONE entity set participating in a relation.
o Example, one person is married to only one person.
• Binary Relationship – TWO entities set participating in a relation.
o Example, Student is enrolled in Course.
• n-ary Relationship – ’n’ entities set participating in a relation.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Component of ER Diagram

Relationship –

Cardinality:
• number of times an entity of an entity set participates in a relationship.
• One to one – each entity in each entity set can take part only once in the relationship.
o Example, a male can marry to one female and a female can marry to one male.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Component of ER Diagram

Relationship Cardinality:

• Many to one – entities in one entity set can take part only once in the relationship set and
entities in other entity set can take part more than once in the relationship set.
o Example, student can take only one course but one course can be taken by many students.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Component of ER Diagram

Relationship Cardinality:

• Many to one – entities in one entity set can take part only once in the relationship set and
entities in other entity set can take part more than once in the relationship set.
o Example, student can take only one course but one course can be taken by many students.

• One-to-many relationship… Just opposite of Many-to-one.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Component of ER Diagram

Relationship Cardinality:

• Many to many – entities in all entity sets can take part more than once in the relationship.
o Example, student can take more than one course and one course can be taken by many students.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Participation Constraint:
• Total Participation – Each entity in the entity set must participate in the relationship.
• shown by double line in ER diagram.
o Example, each student must enroll in a course.
• Partial Participation – The entity in the entity set may or may NOT participate in the relationship.
o Example, some courses are not enrolled by any of the student.

• Student Entity set having total participation and Course Entity set having partial participation.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G
Converting ER to Table/Schema

• Each entity type becomes a table.


• All single-valued attribute becomes a column for the table.
• A key attribute of the entity type represented by primary key.
• Multivalued attribute is represented by a separate table.
• Composite attribute represented by components.
• Derived attributes are not considered in table.

SSS Shameem Apr-2022 Database Management, MSc., DOC


D ATA M O D E L L I N G

SSS Shameem Apr-2022 Database Management, MSc., DOC

You might also like