Chapter 3 Slide-Lecture
Chapter 3 Slide-Lecture
Database Modeling
Daniel Tesfay
Introduction to ODL
₋ Composite attributes can be divided into smaller subparts, which represent more basic
attributes with independent meanings. The value of a composite attribute is the concatenation
of the values of its constituent simple attributes.
₋ Atomic Attributes: Attributes that are not divisible are called simple or atomic attributes.
₋ Most attributes have a single value for a particular entity; such attributes are
called single-valued.
4
Types of Attributes
o Null Values
₋ In some cases a particular entity may not have an applicable value for an attribute. For example,
a person with no college degree would have null for College_Degrees.
o Complex Attributes
₋ Is a result of composite and multi-valued attributes which are nested in an arbitrary way
5
Example Company Database
o We store each EMPLOYEE’s social security number, address, salary, Gender, and
birthdate.
₋ Each employee works for one department but may work on several projects.
₋ We keep track of the number of hours per week that an employee currently
works on each project.
₋ We also keep track of the direct supervisor of each employee.
o Each employee may have a number of DEPENDENTs.
₋ For each dependent, we keep track of their name, Gender, birthdate, and
relationship to the employee.
Entities and Attributes
o Entities are specific objects or things in real-world that are represented in the database.
₋ For example, the EMPLOYEE Abebe Kebede, the Research DEPARTMENT, the ProductX
PROJECT
o Attributes are properties used to describe an entity.
₋ For example an EMPLOYEE entity may have the attributes Name, SSN, Address, Sex,
BirthDate
o A specific entity will have a value for each of its attributes.
₋ For example a specific employee entity may have Name=‘Abebe Kebede',
SSN='123456789', Address =‘Hawassa, Tabor kifle ketema, kebele ___’, Gender='M',
BirthDate='09-JAN-55‘
o Each attribute has a value set (or data type) associated with it – e.g. integer, string,
subrange, enumerated type, …
Entity Types and Key Attributes
o Entities with the same basic attributes are grouped or typed into an entity type.
₋ For example, the entity type EMPLOYEE and PROJECT.
o An attribute of an entity type for which each entity must have a unique value is
called a key attribute of the entity type.
₋ For example, SSN of EMPLOYEE.
Entity Types and Key Attributes
11
ER Diagram Notations
12
ER Diagram
Relationships and Relationship Types
₋ A relationship relates two or more distinct entities with a specific meaning. For
example, EMPLOYEE Abebe Kebede works on the ProductX PROJECT or
EMPLOYEE Zinash Solomon manages the Research DEPARTMENT.
₋ Relationships of the same type are grouped or typed into a relationship type. For
example, the WORKS_ON relationship type in which EMPLOYEEs and
PROJECTs participate, or the MANAGES relationship type in which
EMPLOYEEs and DEPARTMENTs participate.
₋ The degree of a relationship type is the number of participating entity types. Both
MANAGES and WORKS_ON are binary relationships. Relationship types of
degree 2 are called binary. Relationship types of degree 3 are called ternary and
of degree n are called n-ary
Role Names and Recursive Relationships
o The role name signifies the role that a participating entity from the entity type plays in each
relationship instance, and helps to explain what the relationship means. For example, in the
WORKS_FOR relationship type, EMPLOYEE plays the role of employee or worker and
DEPARTMENT plays the role of department or employer.
o In some cases the same entity type participates more than once in a relationship type in
different roles. Such relationship types are called recursive relationships. The
SUPERVISION relationship type relates an employee to a supervisor, where both employee
and supervisor entities are members of the same EMPLOYEE entity type. Hence, the
EMPLOYEE entity type participates twice in SUPERVISION: once in the role of
supervisor (or boss), and once in the role of supervisee (or subordinate).
15
Attributes of Relationship Types
16
Refining the Company database schema by introducing relationships
₋ An employee can work for exactly one department but a department can have any
number of employees.
• Specify (1,1) for participation of EMPLOYEE in WORKS_FOR
Diagramming Methodology
o Disjointness (disjointedness):
o Disjoint Specialization
₋ specifies whether the subclass in specialization are disjoint(i.e. an entity belongs to
only one sub class)
₋ An entity can’t be member of more than one class
₋ It avoids the overlapping specialization
o Overlapping Specialization
₋ If the subclasses are not constrained to be disjoint, their sets of entities may be
overlapping;
₋ An entity may be a member of more than one subclass of the specialization.
Completeness Constraint
o Completeness Constraint
₋ It may be total or partial.
₋ A total specialization constraint: specifies that every entity in the
superclass must be a member of at least one subclass in the
specialization.(Double Line notation)
₋ A Partial Specialization: An entity in the superclass may not belong to any
subclass. This means there are some entities in the superclass that might
not be classified into any subclass. (Single line notation )
ER Diagram for Exercise 1
Exercises
Instructions
o In the next three slides, you will find the conceptual database designs for
various departments, including Company Database, Sales Database, and
University Database. Based on these conceptual database designs, please
complete the following tasks:
4. Create the Database from the physical model by connecting to your database engine.
Company Database Conceptual Schema
Exercise: SalesDB Database
o The SalesDB system is intended to manage sales transactions in a car dealership.
The system must keep track of the following: The system should allow us to
store details of customers who purchase cars, including their full name, phone
number, and email. Customers may purchase multiple cars over time, so the
system must associate each customer with their purchase history.
o Car Inventory: The system must maintain a record of all cars available for sale,
including the car's make, model, year, and price. Once a car is sold, it should be
linked to the corresponding sales record and removed from the available
inventory.
Exercise: SalesDB Database conn..
1. Employee Records:
1. The system should track employees responsible for processing car sales. This includes
storing employee names, their position in the dealership, and contact details.
2. Each invoice must be linked to the employee who handled the transaction.
2. Invoices:
1. Every sale must generate an invoice that includes the date of purchase, the total
amount, the customer who purchased the car, the employee who handled the
transaction, and the specific car that was sold.
2. The system should ensure that each car sale is associated with exactly one invoice.
SalesDB Database Conceptual Schema
Exercise to University Database