Assignment-1 DBMS BCSC1003 EVEN
Assignment-1 DBMS BCSC1003 EVEN
Instructions: Student have to submit one set only as assigned according to roll no.
Date of Issue: 31st Jan, 2024. Submission Date: 28th Feb, 2024
Assignment 1
Further, the enrollment of students in courses and grades awarded to students in each course they are
enrolled for must be appropriately modeled. Construct an E-R diagram for the registrar’s office.
Document all assumptions that you make about the mapping constraints.
2. Consider the following schema: Suppliers (sid : integer, sname : string, address : string) Parts (pid :
integer, pname : string, color : string) Catalog (sid : integer, pid : integer, cost : real) The key fields
are underlined and domain of each field is listed after the field name
a. Find the name of suppliers who supply some red parts
b. Find the sids of suppliers who supply some red or green parts
c. Find the sids of suppliers who supply some red part or are at 221 packer Av
3. Suppose you are Data Base Administrator (DBA) working in sports Department and you are
designing a Database for the National Hockey League with following requirement and the
constraints
NHL- may have n number of teams and each team is having attribute a name, a city, a coach, a
captain, and a set of players,
Each player has a name, a position (such as left wing or goalie), a skill level, and a set of injury
records,
a game is played between two teams (referred to as host_team and guest_team) and has a date
(such as May 11th, 2020) and a score (such as 4 to 2) of winning team is to be recorded.
4. Consider the following relations for a database that keeps track of student enrollment in courses
and the books adopted for each course:
1|Page
Theory
Assign
ment
STUDENT(Ssn, Name, Major, Bdate) COURSE(Course#, Cname, Dept)
ENROLL(Ssn, Course#, Quarter, Grade) BOOK_ADOPTION(Course#, Quarter, Book_isbn)
TEXT(Book_isbn, Book_title, Publisher, Author)
Specify the foreign keys for this schema, stating any assumptions you make.
2|Page
Theory Assignment
Assignment 1
1. A task ofanalyzing database is given to the Database Administrator of the company having
the following relational database and give an expression in relational algebra each of the following
queries:
Employee (person-name, street, city)
Works (person name, company name, salary)
Company (Company name, city)
Managers (person name, manager-name)
(a) Convert these relations into ER model and specify Primary Key, Foreign Key, Candidate Key and
Super Key in these relations.
(b) Find the names of all employees who work for First Bank Corporation.
(c) Find the names and cities of residences of all employees who work for First Bank Corporation.
(d) Find the names of all the employees who do not work for First Bank Corporation.
(e) Find names of all employees who earn more than $10000 per annum.
(f) Find names of all employees who earn more than every employee of Small Bank Corporation.
2. Design an ERD for an e-commerce website. The website has multiple products, each
identified by a unique product ID, and has attributes like name, price, and quantity in stock.
Customers have unique customer IDs and attributes such as name, email, and shipping address.
Customers can place multiple orders, and each order can include multiple products. Each product can
belong to multiple orders.
3. Consider a scenario where a table has an attribute that can have NULL values. Should you
use this attribute as part of the Primary Key or Candidate Key? Justify your answer.
5. In a university database, you have the following entities: Students, Courses, and Enrollments.
Design appropriate tables for each entity and establish the necessary keys and relationships using
primary keys and foreign keys.
3|Page
Theory Assignment
6. Let a Relation R have attributes {a1, a2, a3,…, an} and the candidate key is “a1 a2 a3” then
the possible number of super keys?
7. Consider the following six relations for an order-processing database appli- cation in
a company:
CUSTOMER(Cust#, Cname, City) ORDER(Order#, Odate, Cust#, Ord_amt) ORDER_ITEM(Order#, Item#, Qty)
ITEM(Item#, Unit_price)
SHIPMENT(Order#, Warehouse#, Ship_date) WAREHOUSE(Warehouse#, City)
Here, Ord_amtrefers to total dollar amount of an order; Odateis the date the order was placed; and
Ship_dateis the date an order (or part of an order) is shipped from the warehouse. Assume that an
order can be shipped from sev- eral warehouses. Specify the foreign keys for this schema,
stating any assumptions you make. What other constraints can you think of for this database?
8. Consider the following relational database schema consisting of the four relation
schemas: passenger (pid, pname, pgender, pcity)
agency ( aid, aname, acity) flight
(fid, fdate, time, src, dest)
booking (pid, aid, fid, fdate)
Answer the following questions using relational algebra queries;
4|Page
Theory Assignment
Assignment 1
1. Consider the following relations for a database that keeps track of business trips
of salespersons in a sales office:
A trip can be charged to one or more accounts. Specify the foreign keys for this schema,
stating any assumptions you make.
2. Suppose you have a table with the following attributes: Employee_ID, Employee_Name, and
Department_ID. Designate the Primary Key and Foreign Key(s) for this table, assuming it has a
relationship with a department table with a primary key Department_ID.
(a) AE, BE
(b) AE, BE, DE
(c) AEH, BEH, BCH
(d) AEH, BEH, DEH
4. Draw ER diagram and Map it to Relational Schema and Map it to Relational Schema
In an educational institute, there are several departments and each student belongs to one of them.
Each department has a unique department number, a name, a location, phone number and is headed
by a professor. Professors have a unique employee Id, name and a phone number. A professor works
for exactly one department.
We like to keep track of the following details regarding students: name, unique roll number, sex,
phone number, date of birth, age and one or more email addresses. Students have a local address
consisting of the hostel name and the room number. They also have home address consisting of house
number, street, city and PIN. It is assumed that all students reside in the hostels.
A course taught in a semester of the year is called a section. There can be several sections of the same
course in a semester; these are identified by the section number. Each section is taught by a professor
and has its own timings and a room to meet. Students enroll for several sections in a semester.
Each course has a name, number of credits and the department that offers it. A course may have other
courses as pre-requisites i.e, courses to be completed before it can be enrolled in.
Professors also undertake research projects. These are sponsored by funding agencies and have a
specific start date, end date and amount of money given. More than one professor can be involved in a
5|Page
Theory Assignment
project. Also a professor may be simultaneously working on several projects. A project has a unique
projectId
5. Let a Relation R have attributes {a1, a2, a3,…, an} and the candidate keys are “a1”, “a2 a3” then
the possible number of super keys?
6. Cardinality ratios often dictate the detailed design of a database. The cardinality ratio depends on
the real-world meaning of the entity types involved and is defined by the specific application. For
the following binary relation- ships, suggest cardinality ratios based on the common-sense
meaning of the entity types. Clearly state any assumptions you make.
SUPPLIER(Sno, Sname)
PART(Pno, Pname)
PROJECT(Jno, Jname)
SUPPLY(Sno, Pno, Jno)
The database records information about suppliers, parts, and projects and includes a ternary
relationship between suppliers, parts, and projects. This relationship is a many-many-many
relationships. Specify and execute the fol- lowing queries using the RA interpreter.
a. Retrieve the part numbers that are supplied to exactly two projects.
b. Retrieve the names of suppliers who supply more than two parts to project‘J1’.
c. Retrieve the part numbers that are supplied by every supplier.
d. Retrieve the project names that are supplied by supplier ‘S1’ only.
e. Retrieve the names of suppliers who supply at least two different parts each to at least two
different projects.
8. Consider the ER diagram mentioned below. Identify the entity sets, attributes & convert the
following ER diagram to set of relational schemas.
6|Page
Theory Assignment
9. Assume that a task is assigned to you to explore the below provided relations and find the
different type of dependencies exist in these relations as well as the highest normal form.
Relation-1 Student (RNo, Name, D.O.B, Age, Course_no, Course_name, Instructor, Grade)
Sam C1 1234 10
Jack C1 1278 11
Krish C2 1265 10
Jerry C2 1233 11
7|Page
Theory
Assignmen
t
1-23-45 Computer Mcgraw- USA
Graphics Hill
2-35-46 System Pearson China
Programming
8|Page
Theory Assignment
Assignment 1
1. Design an E-R diagram for keeping track of the exploits of your favorite sports team. You should
store the matches played, the scores in each match, the players in each match and individual player
statistics for each match. Summary statistics should be modeled as derived attributes.
3. Let a Relation R have attributes {a1, a2, a3,…, an} and the candidate keys are “a1 a2”, “a1 a3”
then the possible number of super keys?
4. Construct an E-R diagram for a hospital with a set of patients and a set of medical doctors.
Associate with each patient a log of the various tests and examinations conducted.
CD -> AC
BD -> CD
BC -> CD
AC -> BC
B->E
9|Page
Theory
Assignm
ent
6. A database is being constructed to keep track of the teams and games of a sports league. A
team has a number of players, not all of whom participate in each game. It is desired to keep
track of the players participating in each game for each team, the positions they played in
that game, and the result of the game. Design an ER schema diagram for this application,
stating any assumptions you make. Chooseyourfavorite sport (e.g., soccer, baseball, football).
7. Consider the ER diagram mentioned below. Identify the entity sets, attributes &Convert the ER
model into a relational Schema.
10 | P a g e
Theory Assignment
Assignment 1
1. Analyze the given ERD & reduce the following ER diagram to relational database
schema. Identify Candidate keys & determine total numbers of Tables required.
2. Analyze a given dataset and identify various mapping constraints that need to be applied to ensure
data integrity. Your dataset includes information about employees in a company, such as their
names, ages, departments, and salaries. Consider the following constraints:
i. Primary Key Constraint: Identify the primary key(s) for the "Employee" table and explain why
they are suitable for uniquely identifying each record.
ii. Foreign Key Constraint: Determine the foreign keys in the "Employee" table that reference other
tables (e.g., "Department" table) and explain the relationships between them.
iii. Unique Constraint: Identify attributes that should have unique values for each record in the
"Employee" table.
iv. Not Null Constraint: Identify attributes that must have a value for every record in the "Employee"
table.
v. Check Constraint: Suggest a check constraint for the "Salary" attribute to ensure that it falls within
a specific range (e.g., between $30,000 and $100,000).
11 | P a g e
Theory Assignment
3. Consider a database for an educational institution that offers various courses. Design a database
schema to represent the entities "Course," "RegularCourse," and "WorkshopCourse" using
specialization and generalization.
4. Compute the closure of the following set F of functional dependencies for relation schema r (A, B,
C, D, E).
A→BC
CD→E
B→D
E→A
List the candidate keys for R.
5. Consider the following set F of functional dependencies on the relation schema r(A, B, C, D, E, F):
A→BCD
BC→DE
B→D
D→A
a. Compute B + .
b. Prove (using Armstrong’s axioms) that AF is a superkey.
c. Compute a canonical cover for the above set of functional dependen- cies F ; give each step
of your derivation with an explanation.
12 | P a g e
Theory
Assignment
8. Draw ER
Diagram for
the scenario
below and
map it to
Relational
Schema: -
We store each employee’s name (first, last, MI), Social Security number (SSN), street address, salary,
sex (gender), and birth date. An employee is assigned to one department, but may work on several
projects, which are not necessarily controlled by the same department. We keep track of the current
number of hours per week that an employee works on each project. We also keep track of the direct
supervisor of each employee (who is another employee).
Each department has a particular employee who manages the department.
We want to keep track of the dependents of each employee for insurance purposes. We keep each
dependent’s first name, sex, birth date, and relationship to the employee
A department controls a number of projects which has a unique number and a single location.
13 | P a g e