DBMS All Assignments + Solutions
DBMS All Assignments + Solutions
Question 1.
Draw an ER schema diagram for geography. It should contain the following kinds of entities together with
the listed attributes:
• Countries : Name, Area, Population, GDP ("Gross Domestic Product")
• Cities : Name , Population , Longitude , Latitude
• Rivers : Name , Length
• Seas : Name , Max depths
State any assumptions you make about the additional requirements. (10 marks)
Make sure that you indicate all cardinality constraints and your model should not contain redundant
entity sets, relationships, or attributes. If you need to make any assumptions, include them in your answer.
Each airplane has a registration number [Reg#], belongs to a particular plane type [OF-TYPE],
and is stored in a particular hangar [STORED-IN]. Each airplane can only belong to one plane
type and be stored in one hangar, but each hangar can store multiple airplanes.
Each plane type has a model number [Model], a capacity [Capacity], and a location [Location].
Each plane type can have multiple airplanes, but each airplane belongs to only one plane
type.
The database keeps track of the owners of each plane [OWNS] and the employees who have
maintained the plane [MAINTAIN]. Each airplane can have multiple owners over time, but an
owner can own many airplanes. Each relationship instance in OWNS relates an airplane to an
owner and includes the purchase date [Pdate].
Each relationship instance in MAINTAIN relates an employee to a service record [SERVICE].
Each airplane can have many service records, and an employee can maintain many
airplanes. Each plane undergoes service many times; hence, it is related by [PLANE-SERVICE]
to a number of service records. A service record includes the date of maintenance [Date], the
number of hours spent on the work [Hours], and the type of work done [Workcode]. Each
service record is uniquely identified by the airplane registration number and the service
instance (this makes SERVICE a weak entity).
Pilots have specific attributes like license number [Lic-Num] and restrictions [Restr], while
employees have attributes such as salary [Salary] and shift worked [Shift]. Each person (whether
a pilot or an employee) in the database has data kept on their social security number [Ssn], name
[Name], address [Address], and telephone number [Phone].
The database also tracks the types of planes each pilot is authorized to fly [FLIES] and the types
of planes each employee can do maintenance work on [WORKS-ON]. A pilot can be authorized
to fly multiple plane types, and multiple pilots can be authorized for the same plane type.
Similarly, an employee can maintain multiple plane types, and multiple employees can work
on the same plane type.
Question 5. (15 marks)
A library service wants to create a database to store details of its libraries, books and borrowers. Details
include the following:
A book has a unique ISBN number, a title and one or more authors. The library service may own several
copies of a given book, each of which is located in one of the service’s libraries. A given library contains
many books, and in order to distinguish different copies of the same book a library assigns a different
copy-number to each of its copies of a given book; the price that was paid for each copy is also recorded.
Every library has a unique name and is either a main library or a branch library. A main library may have
zero or more branch libraries and every branch library is a branch of exactly one main library.
A borrower has a name and a unique ID code. A borrower can have many books on loan, but each copy
of a book can only be on loan to one borrower. A borrower could borrow the same book on several
occasions, but it is assumed that each such loan will take place on a different date.
Draw an EER Model for above requirement.
Name
GDP
M 1
Cities Belongs to Countries
M M
Crosses
M
Name
1 M 1
Seas Ends In Rivers Ends In
MaxDepths
Length 1
Name
C_Name
StateName StartDate
District
Region
PoliticalParty
M M
DateOfVote
Sponsored Votes
M
N N
M
Bill
BillName
PassedOrFailed
Yes No
NotApproved
Approved Pending
Address
M 1
TimeCard Submits Employee
Approves
Manages
1 1
Manager
M_ID
Name
Salary Shift
Capacity M
M
Model Weight works on
Employee
M
PlaneType
maintain
1
M Restr Lic-Num
of type
M
M M
flies Pilot
Reg._No,
Airplane Date Workcode
Hangar
M Owner
M
owns
Location
Corporation Person
Number Capacity Name
SSN
Address Address
Phone Name
Phone
Title Author
ISBN
Book
Price Copy
B_ID Date
Name CopyNo.
M
1 M M 1
Barrower Barrow Loan to Copy
Location
No,-of-branches
Name
1
Library
Main Branch
1 M
Branch
DepartureAddress
TripID
DestinationAddress
PersonalNumber
DepartureTime
Address
1 M Trip
Operator Assigns DestinationTime
M
M
Employee
1 1
Drives
Driver
M
Has Uses
LicenseType Assigned
LicenseDate 1
M CertificateDate
PhoneNumber
1
CarID
Car
Number Type
Yearofmanufacturing LastServiceDate
No.ofPlaces
National University of Computer and Emerging Sciences, Lahore Campus
Course: Database systems Course Code: CS5059
Program: MSBA Semester: Fall 2024
Deadline Marks: 100
Question 1.
The Olympic facilities are divided into sports complexes. Sports complexes are divided into
onesport and multisport types. Multisport complexes have areas of the complex designated for
each sport with a location indicator (e.g., center, NE corner, and so on). A complex has a
location, chief organizing individual, total occupied area, and so on. Each complex holds a
series of events (e.g., the track stadium may hold many different races). For each event there is
a planned date, duration, number of participants, number of officials, and so on. A roster of all
officials will be maintained together with the list of events each official will be involved in.
Different equipment is needed for the events (e.g., goal posts, poles, parallel bars) as well as
for maintenance. The two types of facilities (one-sport and multisport) will have different types
of information. For each type the number of facilities needed is kept, together with an
approximate budget.
Question2:
Convert the following EER Diagram into a Database Schema. Make sure to reduce redundancy as much
as possible. Efficient tables will be given credit only. Mark primary and foreign keys as well. (10 marks)
Question 3:
Convert the following ER Diagram into a Database Schema. Make sure to reduce redundancy as much
as possible. Efficient tables will be given credit only. Mark primary and foreign keys as well. (15 marks)
Question 4:
Convert the following ER Diagram into a Database Schema. Make sure to reduce redundancy as much
as possible. Efficient tables will be given credit only. Mark primary and foreign keys as well. (15 marks)
Question 5: Convert the following EER Diagram into a Database Schema. Clearly identify primary and
foreign keys. (20 marks)
Question 6:
Convert the following EER Diagram into a Database Schema. Make sure to reduce redundancy as much
as possible. Efficient tables will be given credit only. Mark primary and foreign keys as well. (20 marks)
Answer 1: 20 marks
Answer 2: 10 marks
Answer 3: 15 marks
1. SHIP Table:
● Attributes:
○ Sname (Primary Key)
○ Owner
○ Type (Foreign Key to SHIP_TYPE)
○ Home_Port (Foreign Key to PORT)
2. SHIP_TYPE Table:
● Attributes:
○ Type (Primary Key)
○ Tonnage
○ Hull
3. SHIP_AT_PORT Table:
This table represents the relationship where a ship can be at multiple ports. It has a
many-to-many relationship between SHIP and PORT.
● Attributes:
○ Sname (Foreign Key to SHIP)
○ Pname (Foreign Key to PORT)
○ Start_date
○ End_date
4. PORT Table:
● Attributes:
○ Pname (Primary Key)
○ State_Country (Foreign Key to STATE/COUNTRY)
○ Sea_Ocean_Lake (Foreign Key to SEA/OCEAN/LAKE)
5. STATE/COUNTRY Table:
● Attributes:
○ Name (Primary Key)
○ Continent
6. SEA/OCEAN/LAKE Table:
● Attributes:
○ Name (Primary Key)
7. SHIP_MOVEMENT Table:
● Attributes:
○ Sname (Foreign Key to SHIP)
○ Date
○ Time
○ Longitude
○ Latitude
8. HISTORY Table:
● Attributes:
○ Sname (Foreign Key to SHIP)
○ Time_stamp (Primary Key)
9. PORT_VISIT Table:
● Attributes:
○ Sname (Foreign Key to SHIP)
○ Pname (Foreign Key to PORT)
○ Start_date
○ End_date
Answer 4: 15 marks
1. BANK Table
● Attributes:
○ Code (Primary Key)
○ Name
○ Addr (Address)
2. BANK_BRANCH Table
● Attributes:
○ Branch_no (Primary Key)
○ Addr (Address)
○ BankCode (Foreign Key from BANK)
3. ACCOUNT Table
● Attributes:
○ Acct_no (Primary Key)
○ Balance
○ Type (Type of account, e.g., savings, checking)
○ Branch_no (Foreign Key from BANK_BRANCH)
4. LOAN Table
This table stores information about loans taken from the bank.
● Attributes:
○ Loan_no (Primary Key)
○ Amount
○ Type (Type of loan)
○ Branch_no (Foreign Key from BANK_BRANCH)
5. CUSTOMER Table
● Attributes:
○ Ssn (Primary Key)
○ Name
○ Phone
○ Addr (Address)
This table handles the many-to-many relationship between ACCOUNT and CUSTOMER.
● Attributes:
○ Acct_no (Foreign Key from ACCOUNT)
○ Ssn (Foreign Key from CUSTOMER)
This table handles the many-to-many relationship between LOAN and CUSTOMER.
● Attributes:
○ Loan_no (Foreign Key from LOAN)
○ Ssn (Foreign Key from CUSTOMER)
Relationships:
Answer 5: 20 marks
1. PHOTO Table
● Attributes:
○ PhotoID (Primary Key)
○ Speed
○ Film
○ F-Stop
○ Color_BW (Boolean for Color or B&W)
○ Resolution
○ Date
○ Price
2. PHOTOGRAPHER Table
● Attributes:
○ PName (Primary Key)
○ PBDate (Date of Birth)
○ PBio
○ PAddress
○ PNationality
3. TAKES Table
● Attributes:
○ PhotoID (Foreign Key from PHOTO)
○ PName (Foreign Key from PHOTOGRAPHER)
4. LOCATION Table
● Attributes:
○ Place (Primary Key)
○ Country
○ Description
5. LANDSCAPE Table
This table stores information specific to landscape photos and has a relationship with
LOCATION.
● Attributes:
○ PhotoID (Foreign Key from PHOTO)
○ Place (Foreign Key from LOCATION)
6. ABSTRACT Table
● Attributes:
○ PhotoID (Foreign Key from PHOTO)
○ Comment
7. MODEL Table
● Attributes:
○ MName (Primary Key)
○ MBio
○ MSex
○ MBDate (Birthdate)
8. PORTRAIT Table
This table stores information specific to portrait photos and has a relationship with
MODEL.
● Attributes:
○ PhotoID (Foreign Key from PHOTO)
○ MName (Foreign Key from MODEL)
○ Agency
9. TRANSACTION Table
● Attributes:
○ TransID (Primary Key)
○ TDate
○ TotalAmount
○ CardNo
○ CardType
○ CardExpDate
● Attributes:
○ LoginName (Primary Key)
○ Password
○ CName
○ CType
○ BillingAddress
○ CAddress (Foreign Key from CUSTOMER_ADDRESS)
● Attributes:
○ StreetAddress1
○ StreetAddress2
○ City
○ State
○ ZipCode
This table defines the relationship between PHOTO and TRANSACTION (a photo can be
part of multiple transactions, and a transaction can include multiple photos).
● Attributes:
○ PhotoID (Foreign Key from PHOTO)
○ TransID (Foreign Key from TRANSACTION)
● Attributes:
○ PName1 (Foreign Key to PHOTOGRAPHER)
○ PName2 (Foreign Key to PHOTOGRAPHER)
Answer 6: 20 marks
1. USER Table
● Attributes:
○ UserID (Primary Key)
○ Username
○ Password
○ Name
○ Address
○ Gender
○ Education
○ University
○ Mobile
2. STUDENT Table
● Attributes:
○ S_ID (Primary Key)
○ Name
○ DOB (Date of Birth)
○ Fees
○ Gender
○ Phone
3. TEACHER Table
● Attributes:
○ UserID (Foreign Key from USER)
○ Courses
4. HEADMASTER Table
● Attributes:
○ UserID (Foreign Key from USER)
○ YearsOfService
5. CLASS Table
● Attributes:
○ C_ID (Primary Key)
○ ClassLevel
○ NumberOfStudents
○ Location
6. STUDENT_ASSESSMENT Table
● Attributes:
○ SA_ID (Primary Key)
○ WritingLevel
○ ReadingLevel
○ CleaningSkills
○ Attendance
○ Participation
7. TEACHER_ASSESSMENT Table
● Attributes:
○ TA_ID (Primary Key)
○ Attendance
○ TeachingSkills
○ Technology
○ Interaction
○ Preparation
This table stores the many-to-many relationship between STUDENT and CLASS (students
are enrolled in classes).
● Attributes:
○ S_ID (Foreign Key from STUDENT)
○ C_ID (Foreign Key from CLASS)
9. TEACHES Table
This table stores the relationship between TEACHER and CLASS (teachers teach multiple
classes).
● Attributes:
○ UserID (Foreign Key from TEACHER)
○ C_ID (Foreign Key from CLASS)
● Attributes:
○ S_ID (Foreign Key from STUDENT)
○ SA_ID (Foreign Key from STUDENT_ASSESSMENT)
11. TEACHER_ASSESSMENT_RELATION Table
● Attributes:
○ UserID (Foreign Key from TEACHER)
○ TA_ID (Foreign Key from TEACHER_ASSESSMENT)
This table stores the relationship between HEADMASTER and TEACHER (headmasters
oversee teachers).
● Attributes:
○ UserID_Headmaster (Foreign Key from HEADMASTER)
○ UserID_Teacher (Foreign Key from TEACHER)
Relationships: