1426357293.3273chapter 2 in-class exercises
TRANSCRIPT
-
8/17/2019 1426357293.3273chapter 2 in-class Exercises
1/12
Chapter 2 Exercises Page 1
Fundamentals of Database systems
Chapter 2 – In Class Exercises
-
8/17/2019 1426357293.3273chapter 2 in-class Exercises
2/12
Chapter 2 Exercises Page 2
• The entity type STUDENT has the following
attributes: student-name, address, hair-color,
phone, age, activity, and number-of-years.Activity represents some campus-based
student activity, and number-of-years
represents the number of years the student
has engaged in this activity.
• A given student may engage in more than oneactivity.
Scenario #1
-
8/17/2019 1426357293.3273chapter 2 in-class Exercises
3/12
Chapter 2 Exercises Page 3
Student
student-name
address
hair-color
{ phone }
age
{ activity-history ( activity-name, number-of-years ) }
ERD For Scenario #1
Simple attributes
Multi-valued attribute
Composite attribute
Identifier
-
8/17/2019 1426357293.3273chapter 2 in-class Exercises
4/12
Chapter 2 Exercises Page 4
• A company has a number of employees. The attributes ofEMPLOYEE include Emp_ID (identifier), Name, Address, andBirthdate.
• The company also has several projects. Attributes of PROJECTinclude Proj_ID (identifier), Proj_Name, and Start_Date.
• Each employee may be assigned to one or more projects, or maynot be assigned to any project.
• A project must have at least one employee assigned to it, andmay have any number of employees assigned to it.
• An employee’s billing rate may vary by project, and thecompany wishes to record the billing rate (Billing_Rate) foreach employee when assigned to a particular project.
Scenario #2
-
8/17/2019 1426357293.3273chapter 2 in-class Exercises
5/12
Chapter 2 Exercises Page 5
ERD For Scenario #2
Attribute of therelationship
Optionalparticipation.
Not every
employee works ona project.
Mandatory
participation.
Every project musthave an employee .
Employee
employee-idemp-name
addressbirthdate
Project
project-idproject-name
start-date
billing-rate
-
8/17/2019 1426357293.3273chapter 2 in-class Exercises
6/12
Chapter 2 Exercises Page 6
• A university has a large number of courses in itscatalog.
• Attributes of COURSE include Course-number(identifier), Course-Name, and credit-hours.
• Each course may have one or more different courses
as prerequisites, or may have no prerequisites.
• Similarly, a particular course may be a prerequisite forany number of courses, or may not be a prerequisite
for any other course.
Scenario #3
-
8/17/2019 1426357293.3273chapter 2 in-class Exercises
7/12
Chapter 2 Exercises Page 7
is-a prerequisite
ERD For Scenario #3
Course
course-numbercourse-namecredit-hours
has-a prerequisite
-
8/17/2019 1426357293.3273chapter 2 in-class Exercises
8/12
Chapter 2 Exercises Page 8
• A university course may have one or morescheduled sections, or it may not have a
scheduled section.
• Attributes of COURSE include Course_ID(identifier), Course_Name, and Credit_Hrs.
• Attributes of SECTION includeSection_Number as identifier and
Semester_ID. Semester_ID is composed oftwo parts: Semester and Year.
Scenario #4
-
8/17/2019 1426357293.3273chapter 2 in-class Exercises
9/12
Chapter 2 Exercises Page 9
ERD For Scenario #4
Course
course-id
course-namecredit-hours
Section
section-number
semester-id (semester, year)
has
-
8/17/2019 1426357293.3273chapter 2 in-class Exercises
10/12
Chapter 2 Exercises Page 10
ERD For Scenario #4
Course
course-id
course-namecredit-hours
Section
section-number
semester-id (semester, year)
Instructor
instructor-idinstructor-nameoffice-number
department
has
teaches
-
8/17/2019 1426357293.3273chapter 2 in-class Exercises
11/12
-
8/17/2019 1426357293.3273chapter 2 in-class Exercises
12/12
Chapter 2 Exercises Page 12
ERD For Scenario #5
This relationship was created to showwhat projects a chemist works on.
All three entities participatein an assignment. However,EQUIPMENT andPROJECT do not need toparticipate in anyassignments. All entitieshave multiple assignments.