SlideShare a Scribd company logo
1 of 42
Download to read offline
DATABASES
FACILITATOR: EMMANUEL KWAMETAKYI
Emmanuel.takyi001@stu.ucc.edu.gh
0246043557
UNITTWO – DATA MODELLING: ENTITY
RELATIONSHIP DIAGRAM
•Relational Model
•Entity relationship diagram
RELATIONAL MODEL
• The relational data model was introduced by C. F. Codd in 1970.
Currently, it is the most widely used data model. The relational
model has provided the basis for:
• Research on the theory of data/relationship/constraint
• Numerous database design methodologies
• The standard database access language called Structured Query
Language (SQL)
• Almost all modern commercial database management systems
The relational data model describes the world as “a collection of
inter-related relations (or tables).
FUNDAMENTAL CONCEPT OF RELATIONAL
MODEL
• Relation
A relation, also known as a table or file, is a subset of the Cartesian
product of a list of domains characterized by a name. And within a
table, each row represents a group of related data values. A row, or
record, is also known as a tuple. The columns in a table is a field and
is also referred to as an attribute.
• Table
A database is composed of multiple tables and each table holds the
data.
FUNDAMENTAL CONCEPT OF RELATIONAL
MODEL conti.
FUNDAMENTAL CONCEPT OF RELATIONAL
MODEL cont.
• Column
A database stores pieces of information or facts in an organized
way. The principal storage units are called columns or fields or
attributes . These house the basic components of data into which
your content can be broken down.
• Records
Records contain fields that are related, such as a customer or an
employee. As noted earlier, a tuple is another term used for record.
FUNDAMENTAL CONCEPT OF RELATIONAL
MODEL cont.
• Properties of aTable
• A table has a name that is distinct from all other tables in the database.
•There are no duplicate rows; each row is distinct.
• Entries in columns are atomic. The table does not contain repeating
groups or multivalued attributes.
• Entries from columns are from the same domain based on their data type
including: number (numeric, integer, float, smallint,…) character (string)
date logical (true or false)
• Operations combining different data types are disallowed.
•Each attribute has a distinct name.
FUNDAMENTAL CONCEPT OF RELATIONAL
MODEL cont.
• Degree
The degree is the number of attributes in a table.
• Domain
Domain is a set of acceptable values that a column is allowed to contain. This
is based on various properties and the data type for the column.
For example:
• The domain of Marital Status has a set of possibilities: Married, Single,
Divorced.
•The domain of Shift has the set of all possible days: {Mon,Tue,Wed…}.
•The domain of Salary is the set of all integer greater than 0 and less than 244.
This simple means, the Marital status column will not accept the “attached” as
data since it is not part of the acceptable data set.
ENTITY RELATIONAL MODEL
• The entity relationship (ER) data model has existed for over 35
years. It is well suited to data modelling for use with databases
because it is fairly abstract and is easy to discuss and explain. ER
models are readily translated to relations. ER models, also called
an ER schema, are represented by ER diagrams. ER modelling is
based on three concepts:
• Entity
• Attribute
• Relationship
ENTITY, ENTITYTYPE AND ENTITY SET
•An entity is an object in the real world with an
independent existence that can be differentiated from
other objects. An entity might be:
•An object with physical existence (e.g., a lecturer, a
student, a car)
•An object with conceptual existence (e.g., a course, a job,
a position)
ENTITY, ENTITYTYPE AND ENTITY SET cont.
ENTITY, ENTITYTYPE AND ENTITY SET cont.
•EntityType
The entity type is a collection of the entity with similar
attributes. In the student table for example, we have each
row as an entity and they all have common attributes.
ENTITY, ENTITYTYPE AND ENTITY SET cont.
Student
E-R representation of Student entity type.
NB: We use rectangle to represent an entity type on E-R diagram
ENTITY, ENTITYTYPE AND ENTITY SET cont.
• Types of Entity type
1.Strong entity type
2.Weak entity type
Strong entity type (s) are entity types with key attribute.The
primary key helps in identifying the strong entity type.
Weak entity type(s) cannot be identified separately.They depend
on other strong entity for their identity.
ENTITY, ENTITYTYPE AND ENTITY SET cont.
ENTITY, ENTITYTYPE AND ENTITY SET cont.
ENTITY, ENTITYTYPE AND ENTITY SET cont.
•Entity set
Entity set is a collection of entities of the same entity type
at a any point in time.
ENTITY, ENTITYTYPE AND ENTITY SET cont.
• Existence dependency
An entity’s existence is dependent on the existence of the related
entity. It is existence-dependent if it has a mandatory foreign key
(i.e., a foreign key attribute that cannot be null). For example, in a
COMPANY database, a Spouse entity is existence -dependent on
the Employee entity.
Existence dependency
INDEPENDENT AND DEPENDENT ENTITIES
• Independent entity does not rely on another entity for
identification.
• Dependent entity relies on another entity for identification.
Independent entity Dependent entity
ATTRIBUTES
• Each entity is described by a set of attributes (e.g., Employee = (Name,
Address, Birthdate (Age), Salary). Each attribute has a name, and is
associated with an entity. In an entity relationship diagram, attribute is
represented by an oval with a name inside.
Name
Attribute represented on E-R diagram
TYPES OF ATTRIBUTES
• Simple attributes
Simple attributes are those drawn from the atomic value domains; they are
also called single-valued attributes. In the STUDENT database, an example of
this would be: Age = {23}.
TYPES OF ATTRIBUTES
• Composite attributes
Composite attributes can be divided into subparts. Using our
database example, Address may consist of Number, Street and
Suburb; Name = Firstname and Lastname.
Student
Name
Address
Birthdate
Number
Street
Suburb
Firstname
Lastname
salary
TYPES OF ATTRIBUTES
• Multivalued attributes
Multivalued attributes are attributes that have a set of values for each entity.
An example of a multivalued attribute from the Employee table below, are the
degrees of an employee: BSc, MIT, PhD. It is important to note that, to
represent multivalued attributes on relational schema, new tables are created.
Employee
Name
Address
salary
Degrees
Degrees
NB: Double ovals are used to represent Multivalued attributes on
E-R diagram
• Derived attributes
Derived attributes are attributes that contain values calculated from other
attributes. An example of this can be seen the E-R diagram below. Age can be
derived from the attribute Birthdate. In this situation, Birthdate is called a
stored attribute, which is physically saved to the database.
TYPES OF ATTRIBUTES
Employee
Name
Address
Birthdate
Age
Age
NB:Dotted oval with name inside represent derived
attributes on E-R diagram
•A key is an attribute or a set of attributes in a relation
that identifies a tuple (record) in a relation.
•Keys are defined in a table to allow access or storage of
data quickly.
•They are also used to create relationship between tables.
KEYS
•Primary key
•Candidate key
•Alternate key
•Super key
•Composite key
•Foreign key
•Unique key
TYPES OF KEYS
•Primary key (PK): It helps to identify
every record present in a table uniquely.
There can be only one primary key in a
table. Every value of a primary key must
different with no repetition. No two row
can have the same primary key.The
primary Key field cannot be null. A null value is either
unknown or not application. It does not mean blank.
TYPES OF KEYS
•Candidate keys : Keys with attributes
that can uniquely identify rows of a table
are called candidate keys.There can be
more than two candidate keys from a table
but they can not be empty or null.The
primary is selected from the candidate keys.
TYPES OF KEYS
•Alternate keys : As stated, a table can
have multiple choice of a primary key,
however, it can choose only one. So, all
the keys which did not become the primary
key are called alternate keys.
TYPES OF KEYS
•Super key : It is set of attributes that
uniquely identifies each tuple of a relation.
Super key is the superset of a candidate
Key.The primary key of a table is picked
from super key set.
TYPES OF KEYS
•Composite key : If a table not have a
single attribute that qualifies for a
Candidate key, then you have to select
two or more columns to make a row
Unique. So, EmployeeName+Date of
Birth are used as primary key.
TYPES OF KEYS
•Foreign key : It is column of a table that points to the
primary key of another table. A foreign key is used to link
to tables. It helps to maintain data and referential
integrity.The DeptID on employee table is a foreign key.
TYPES OF KEYS
•Unique key :It is same as primary with
the difference being the existence of null.
Unique key field allows one value as
NULL value.
TYPES OF KEYS
It is the association between entities or tables. We will
discuss only six relationships in relational model:
•One to one relationship (1:1)
•One to many or many to one relationship (1:M)
•Many to many relationship (M:N)
•Unary relationship (Recursive)
•Binary relationship
•Ternary relationship
NB: Diamond symbol is used to represent relationship in
an E-R diagram.
RELATIONSHIPS
Works
•One to One relationship (1:1): It is used to create a
relationship between two tables in which single row of
the first table can only be related to one and only one
record of the second table.
TYPES OF RELATIONSHIPS
TYPES OF RELATIONSHIPS
•One to Many relationship (1:M): It is used to create a
relationship between two tables. Any single row of the
first table can be related to one or more rows of the
second table. Meanwhile, the rows of the second table
can relate to only one row in the first table.
TYPES OF RELATIONSHIPS
TYPES OF RELATIONSHIPS
•Many to Many relationship (M:N): In M:N relationship,
each record in the first table can relate to more than one
record in the second table. Likewise, a record in the
second table can relate more than one record in the first
table.
TYPES OF RELATIONSHIPS
TYPES OF RELATIONSHIPS
• Unary relationship: It describes a relationship in which a table is
in relationship with itself. One example is an employee database
that keeps track of which employee supervises other employees.
TYPES OF RELATIONSHIPS
• Binary relationship: It describes an association between two
entities.
TYPES OF RELATIONSHIPS
• Ternary relationship: It describes an association among three
entities.This type of relationship is required when binary
relationship is not sufficient to describe the relationshipl

More Related Content

Similar to Database Modelling Guide

Similar to Database Modelling Guide (20)

DATABASE DESIGN.pptx
DATABASE DESIGN.pptxDATABASE DESIGN.pptx
DATABASE DESIGN.pptx
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).ppt
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 
Day 1 SQL.pptx
Day 1 SQL.pptxDay 1 SQL.pptx
Day 1 SQL.pptx
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
 
er-models.pptx
er-models.pptxer-models.pptx
er-models.pptx
 
DATABASE-1.pptx
DATABASE-1.pptxDATABASE-1.pptx
DATABASE-1.pptx
 
entityrelationshipmodel.pptx
entityrelationshipmodel.pptxentityrelationshipmodel.pptx
entityrelationshipmodel.pptx
 
Download different material from slide share
Download different material from slide shareDownload different material from slide share
Download different material from slide share
 
RDBMS ERD
RDBMS ERDRDBMS ERD
RDBMS ERD
 
relationalDatabaseModel.pptx
relationalDatabaseModel.pptxrelationalDatabaseModel.pptx
relationalDatabaseModel.pptx
 
ER MODEL.pptx
ER MODEL.pptxER MODEL.pptx
ER MODEL.pptx
 
Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
 
computer-210809080138.pdf
computer-210809080138.pdfcomputer-210809080138.pdf
computer-210809080138.pdf
 
demo2.ppt
demo2.pptdemo2.ppt
demo2.ppt
 
Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraints
 
Relational Data Model.pptx
Relational Data Model.pptxRelational Data Model.pptx
Relational Data Model.pptx
 
Relational model
Relational modelRelational model
Relational model
 
Dbms keysppt
Dbms keyspptDbms keysppt
Dbms keysppt
 
19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf19IS305_U2_LP4_LM4-22-23.pdf
19IS305_U2_LP4_LM4-22-23.pdf
 

Recently uploaded

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 

Recently uploaded (20)

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 

Database Modelling Guide

  • 2. UNITTWO – DATA MODELLING: ENTITY RELATIONSHIP DIAGRAM •Relational Model •Entity relationship diagram
  • 3. RELATIONAL MODEL • The relational data model was introduced by C. F. Codd in 1970. Currently, it is the most widely used data model. The relational model has provided the basis for: • Research on the theory of data/relationship/constraint • Numerous database design methodologies • The standard database access language called Structured Query Language (SQL) • Almost all modern commercial database management systems The relational data model describes the world as “a collection of inter-related relations (or tables).
  • 4. FUNDAMENTAL CONCEPT OF RELATIONAL MODEL • Relation A relation, also known as a table or file, is a subset of the Cartesian product of a list of domains characterized by a name. And within a table, each row represents a group of related data values. A row, or record, is also known as a tuple. The columns in a table is a field and is also referred to as an attribute. • Table A database is composed of multiple tables and each table holds the data.
  • 5. FUNDAMENTAL CONCEPT OF RELATIONAL MODEL conti.
  • 6. FUNDAMENTAL CONCEPT OF RELATIONAL MODEL cont. • Column A database stores pieces of information or facts in an organized way. The principal storage units are called columns or fields or attributes . These house the basic components of data into which your content can be broken down. • Records Records contain fields that are related, such as a customer or an employee. As noted earlier, a tuple is another term used for record.
  • 7. FUNDAMENTAL CONCEPT OF RELATIONAL MODEL cont. • Properties of aTable • A table has a name that is distinct from all other tables in the database. •There are no duplicate rows; each row is distinct. • Entries in columns are atomic. The table does not contain repeating groups or multivalued attributes. • Entries from columns are from the same domain based on their data type including: number (numeric, integer, float, smallint,…) character (string) date logical (true or false) • Operations combining different data types are disallowed. •Each attribute has a distinct name.
  • 8. FUNDAMENTAL CONCEPT OF RELATIONAL MODEL cont. • Degree The degree is the number of attributes in a table. • Domain Domain is a set of acceptable values that a column is allowed to contain. This is based on various properties and the data type for the column. For example: • The domain of Marital Status has a set of possibilities: Married, Single, Divorced. •The domain of Shift has the set of all possible days: {Mon,Tue,Wed…}. •The domain of Salary is the set of all integer greater than 0 and less than 244. This simple means, the Marital status column will not accept the “attached” as data since it is not part of the acceptable data set.
  • 9. ENTITY RELATIONAL MODEL • The entity relationship (ER) data model has existed for over 35 years. It is well suited to data modelling for use with databases because it is fairly abstract and is easy to discuss and explain. ER models are readily translated to relations. ER models, also called an ER schema, are represented by ER diagrams. ER modelling is based on three concepts: • Entity • Attribute • Relationship
  • 10. ENTITY, ENTITYTYPE AND ENTITY SET •An entity is an object in the real world with an independent existence that can be differentiated from other objects. An entity might be: •An object with physical existence (e.g., a lecturer, a student, a car) •An object with conceptual existence (e.g., a course, a job, a position)
  • 11. ENTITY, ENTITYTYPE AND ENTITY SET cont.
  • 12. ENTITY, ENTITYTYPE AND ENTITY SET cont. •EntityType The entity type is a collection of the entity with similar attributes. In the student table for example, we have each row as an entity and they all have common attributes.
  • 13. ENTITY, ENTITYTYPE AND ENTITY SET cont. Student E-R representation of Student entity type. NB: We use rectangle to represent an entity type on E-R diagram
  • 14. ENTITY, ENTITYTYPE AND ENTITY SET cont. • Types of Entity type 1.Strong entity type 2.Weak entity type Strong entity type (s) are entity types with key attribute.The primary key helps in identifying the strong entity type. Weak entity type(s) cannot be identified separately.They depend on other strong entity for their identity.
  • 15. ENTITY, ENTITYTYPE AND ENTITY SET cont.
  • 16. ENTITY, ENTITYTYPE AND ENTITY SET cont.
  • 17. ENTITY, ENTITYTYPE AND ENTITY SET cont. •Entity set Entity set is a collection of entities of the same entity type at a any point in time.
  • 18. ENTITY, ENTITYTYPE AND ENTITY SET cont. • Existence dependency An entity’s existence is dependent on the existence of the related entity. It is existence-dependent if it has a mandatory foreign key (i.e., a foreign key attribute that cannot be null). For example, in a COMPANY database, a Spouse entity is existence -dependent on the Employee entity. Existence dependency
  • 19. INDEPENDENT AND DEPENDENT ENTITIES • Independent entity does not rely on another entity for identification. • Dependent entity relies on another entity for identification. Independent entity Dependent entity
  • 20. ATTRIBUTES • Each entity is described by a set of attributes (e.g., Employee = (Name, Address, Birthdate (Age), Salary). Each attribute has a name, and is associated with an entity. In an entity relationship diagram, attribute is represented by an oval with a name inside. Name Attribute represented on E-R diagram
  • 21. TYPES OF ATTRIBUTES • Simple attributes Simple attributes are those drawn from the atomic value domains; they are also called single-valued attributes. In the STUDENT database, an example of this would be: Age = {23}.
  • 22. TYPES OF ATTRIBUTES • Composite attributes Composite attributes can be divided into subparts. Using our database example, Address may consist of Number, Street and Suburb; Name = Firstname and Lastname. Student Name Address Birthdate Number Street Suburb Firstname Lastname
  • 23. salary TYPES OF ATTRIBUTES • Multivalued attributes Multivalued attributes are attributes that have a set of values for each entity. An example of a multivalued attribute from the Employee table below, are the degrees of an employee: BSc, MIT, PhD. It is important to note that, to represent multivalued attributes on relational schema, new tables are created. Employee Name Address salary Degrees Degrees NB: Double ovals are used to represent Multivalued attributes on E-R diagram
  • 24. • Derived attributes Derived attributes are attributes that contain values calculated from other attributes. An example of this can be seen the E-R diagram below. Age can be derived from the attribute Birthdate. In this situation, Birthdate is called a stored attribute, which is physically saved to the database. TYPES OF ATTRIBUTES Employee Name Address Birthdate Age Age NB:Dotted oval with name inside represent derived attributes on E-R diagram
  • 25. •A key is an attribute or a set of attributes in a relation that identifies a tuple (record) in a relation. •Keys are defined in a table to allow access or storage of data quickly. •They are also used to create relationship between tables. KEYS
  • 26. •Primary key •Candidate key •Alternate key •Super key •Composite key •Foreign key •Unique key TYPES OF KEYS
  • 27. •Primary key (PK): It helps to identify every record present in a table uniquely. There can be only one primary key in a table. Every value of a primary key must different with no repetition. No two row can have the same primary key.The primary Key field cannot be null. A null value is either unknown or not application. It does not mean blank. TYPES OF KEYS
  • 28. •Candidate keys : Keys with attributes that can uniquely identify rows of a table are called candidate keys.There can be more than two candidate keys from a table but they can not be empty or null.The primary is selected from the candidate keys. TYPES OF KEYS
  • 29. •Alternate keys : As stated, a table can have multiple choice of a primary key, however, it can choose only one. So, all the keys which did not become the primary key are called alternate keys. TYPES OF KEYS
  • 30. •Super key : It is set of attributes that uniquely identifies each tuple of a relation. Super key is the superset of a candidate Key.The primary key of a table is picked from super key set. TYPES OF KEYS
  • 31. •Composite key : If a table not have a single attribute that qualifies for a Candidate key, then you have to select two or more columns to make a row Unique. So, EmployeeName+Date of Birth are used as primary key. TYPES OF KEYS
  • 32. •Foreign key : It is column of a table that points to the primary key of another table. A foreign key is used to link to tables. It helps to maintain data and referential integrity.The DeptID on employee table is a foreign key. TYPES OF KEYS
  • 33. •Unique key :It is same as primary with the difference being the existence of null. Unique key field allows one value as NULL value. TYPES OF KEYS
  • 34. It is the association between entities or tables. We will discuss only six relationships in relational model: •One to one relationship (1:1) •One to many or many to one relationship (1:M) •Many to many relationship (M:N) •Unary relationship (Recursive) •Binary relationship •Ternary relationship NB: Diamond symbol is used to represent relationship in an E-R diagram. RELATIONSHIPS Works
  • 35. •One to One relationship (1:1): It is used to create a relationship between two tables in which single row of the first table can only be related to one and only one record of the second table. TYPES OF RELATIONSHIPS
  • 37. •One to Many relationship (1:M): It is used to create a relationship between two tables. Any single row of the first table can be related to one or more rows of the second table. Meanwhile, the rows of the second table can relate to only one row in the first table. TYPES OF RELATIONSHIPS
  • 39. •Many to Many relationship (M:N): In M:N relationship, each record in the first table can relate to more than one record in the second table. Likewise, a record in the second table can relate more than one record in the first table. TYPES OF RELATIONSHIPS
  • 40. TYPES OF RELATIONSHIPS • Unary relationship: It describes a relationship in which a table is in relationship with itself. One example is an employee database that keeps track of which employee supervises other employees.
  • 41. TYPES OF RELATIONSHIPS • Binary relationship: It describes an association between two entities.
  • 42. TYPES OF RELATIONSHIPS • Ternary relationship: It describes an association among three entities.This type of relationship is required when binary relationship is not sufficient to describe the relationshipl