ER Model
ER Model
ER Model
miniworld
Requirements & collection analysis
Database Requirements
refinement
Conceptual Design
Conceptual Schema (in a high-level data model)
DBMS independent
DBMS specific
Address
Street Address
City=Houston
State=Texas
Zip=77546
Street=Kirby
Apt.=Null
BirthDate=3/17/1936
e1
Types of Attributes
Simple attribute is not divisible (E.g., age).
Composite attribute can be divided into smaller
subparts (e.g., Date (Month, Day, Year)).
Meaning of Null value: unknown or not applicable
addr
student
cid
name
Course
name
ssn
addr
student
entity set
semester
enrolled
cid
name
Course
relationship set
semester
addr
ssn
student
cid
name
course
enrolled
entity set
duration
Advised-by
teach
instructor
relationship set
ssn
name
addr
semester
Structural Constraints
Cardinality Ratio Constraint specifies the
number of relationship instances that an
entity can participate in.
1-to-1
1-to Many
Many-to-1
Many-to-Many
name
ssn
dname
lot
Employees
did
Manages
budget
Departments
Participation Constraint:
Total participation: Every entity in the entity set
participates in the relationship set.
E.g., Every department must have a manager.
ER-Notation:
Partial participation
Each
department
has at most
one manager.
Exercise
A company has a number of employees. The
attributes of EMPLOYEE include Employee_ID
(identifier), Name, Address, and Birthdate.
The company also has several projects. Attributes of
PROJECT include Project_ID (identifier),
Project_Name, and Start_Date.
Each Employee may be assigned to one or more
projects, or may not be assigned to a project.
A project must have at least one employee assigned,
and may have any number of employees assigned.
An employees billing rate may vary by project, and
the company wishes to record the applicable billing
rate (Billing_Rate) for each employee when assigned
to a particular project.
Exercise
A university has a large number of courses in its
catalog. Attributes of COURSE include
Course_number (identifier), Course_name, and Units.
Each course may have one or more different courses
as prerequisites, or may have no prerequisites.
Similarly, a particular course may be a prerequisite
for any number of courses, or may not be
prerequisite for any other course.
Exercise
Weak Entities
A weak entity can be identified uniquely only by
considering some of its attributes and the
primary key of another (owner) entity.
ssn
lot
cost
Employees
Policy
pname
age
Dependents
Weak entity set
ssn
lot
Employees
hours_worked
ISA
Hourly_Emps
contractid
Contract_Emps
Overlap constraints:
name
Covering constraints:
Questions to think
Entity set
Relationship set
Constrains
Key constrain
ISA
Database Requirements:
Maintain the following information about the employees of the company.
[Social security number, date of birth, name, gender, address, salary]
1.
Users want to be able to perform a search on either first name, last name, or middle
name.
2. An employee can have at most one supervisor who is also an employee, but a supervisor
can have more than one supervisees.
3. An employee can have dependents. The dependent name, gender, and date of birth, and
the relationship of the employee and his/her dependent are needed in the database.
4. The company is divided into departments. For each department, the department name,
department number, locations are needed in the database. A department can locate in
several locations.
5. A department can control several projects. Each project must be controlled by only one
department. The name of the project, the project number, and its location need to be
stored in the database.
6. Each employee works on at least one project and each project must have at least one
employee. The number of hours per week that an employee works on a project must be
recorded.
7. Each employee must work for only one department and the department must have at
least one employee. Users also want to query a number of employees in a department.
8. Each department must be managed by one employee. An employee can be a manager of
only one department.
9. The date when the employee becomes a manager for the department needs to be
maintained.
Database Requirements:
Maintain the following information for real estate firm
1. The firm has a number of sales offices in several states. Attributes of
sales offices include Office Number (identifier) and Location.
2. Each sales office is assigned one or more employees. Attributes of
employee include Employee ID (identifier) and Employee Name. An
employee must be assigned to only one sales office.
3. For each sales office, there is always one employee assigned to manage
that office.
4. The firm lists property for sale. Attributes of property include Property
ID (identifier) and Location. Components of Location include Address,
city, State, and Zip Code.
5. Each unit of property must be listed with one (and only one) of the sales
offices. A sales office may have any number of properties listed or may
have no properties listed.
6. Each unit of property has one ore more owners. Attributes of owners are
Owner ID (identifier) and Owner Name. An owner may own one or more
units of property. An attribute of the relationship between property and
owner is Percent Owned.