0% found this document useful (0 votes)
217 views10 pages

Palak Chaturvedi 2K20MC90 Assignment 1

The document contains questions and answers related to database design and modeling. It discusses: 1. Drawing an ER diagram for tracking DVD borrowing between friends, including entities, relationships, attributes, keys, etc. 2. The role of the ER model in the database design process, such as modeling data requirements, identifying entities and relationships, and ensuring consistency between requirements and design. 3. Two approaches for handling multi-valued attributes - converting to a separate entity or to multiple single-valued attributes - and discussing their advantages and disadvantages with an example. 4. How database normalization and keys can help control redundancy in data storage. 5. Conceptual modeling requirements for a training program database, including entities

Uploaded by

Palak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
217 views10 pages

Palak Chaturvedi 2K20MC90 Assignment 1

The document contains questions and answers related to database design and modeling. It discusses: 1. Drawing an ER diagram for tracking DVD borrowing between friends, including entities, relationships, attributes, keys, etc. 2. The role of the ER model in the database design process, such as modeling data requirements, identifying entities and relationships, and ensuring consistency between requirements and design. 3. Two approaches for handling multi-valued attributes - converting to a separate entity or to multiple single-valued attributes - and discussing their advantages and disadvantages with an example. 4. How database normalization and keys can help control redundancy in data storage. 5. Conceptual modeling requirements for a training program database, including entities

Uploaded by

Palak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

MC302: DATABASE MANAGEMENT SYSTEM

Assignment 1
Palak Chaturvedi
2K20/MC/90

Question 1)

Neeta has a large DVD movie collection. Her friends like to borrow her DVD's,
and she needs a way to keep track of who has what. She maintains a list of
friends, identified by unique FID’s (friend's identifier) and a list of DVD's
identified by DVDID's ( DVD's identifier). With each friend is the Name and all-
important telephone numbers which she can call to get the DVD back. With
each DVD is the star actor and actress name and movie title. Whenever a
friend borrows a Neeta will enter the fact into database along with the date
borrowed. Whenever the DVD gets returned, the fact too gets noted along
with the date returned. Neeta wants to keep a complete history of her friend’s
borrowing habits. Draw the ER diagram for this situation. Specify the entities,
relationships, attributes of entities and relationships, cardinality and
participation constraints and also the Primary Keys. Specify clearly any
assumptions that you have made. Suppose in the above question Neeta has a
large collection of music DVDs as well, where each music DVD is identified by
Unique DVDID and has an album_name. Neeta also lends her music DVDs to
her friends and records the borrowed date and returned date as well. What
changes in the ER diagram are required to include these facts? Map the given
ER schema into a relational schema. Specify all the primary and foreign keys.
Answer)

Entities:

1. Friend: Identified by FriendID, with attributes Name and Telephone


Number.
2. DVD (Movie): Identified by DVDID, with attributes Star Actor, Star Actress,
and Movie Title.
3. DVD (Music): Identified by DVDID, with attributes Album Name.
4. Borrow: Represents the borrowing relationship between a friend and a
DVD, with attributes Borrow Date and Return Date.

Relationships:

1. A friend can borrow many DVDs (1:N).


2. A DVD can be borrowed by many friends (N:M).
3. Borrow is the relationship between Friend and DVD entities (N:M).

Attributes of entities and relationships:

1. Friend:
o FriendID (Primary Key)
o Name
o Telephone Number
2. DVD (Movie):
o DVDID (Primary Key)
o Star Actor
o Star Actress
o Movie Title

3. DVD (Music):
o DVDID (Primary Key)
o Album Name

4. Borrow:
o Borrow Date
o Return Date
o FriendID (Foreign Key referencing Friend entity)
o DVDID (Foreign Key referencing DVD entity)

Cardinality and Participation Constraints:

1. A friend must borrow at least one DVD (Mandatory Participation).


2. A DVD must be borrowed by at least one friend (Mandatory Participation).
3. A friend can borrow many DVDs (1:N).
4. A DVD can be borrowed by many friends (N:M).

Relational Schema:

Friend (FriendID, Name, Telephone Number)


DVD (DVDID, Star Actor, Star Actress, Movie Title)
Music_DVD (DVDID, Album Name)
Borrow (FriendID, DVDID, Borrow Date, Return Date)

Primary Keys:

1. Friend: FriendID
2. DVD: DVDID
3. Music_DVD: DVDID
4. Borrow: (FriendID, DVDID)

Foreign Keys:

1. Borrow: FriendID (referencing Friend)


2. Borrow: DVDID (referencing DVD)

Assumptions:

1. A friend is identified by a unique FriendID.


2. A DVD is identified by a unique DVDID.
3. A Borrow relationship between a friend and a DVD is identified by a
combination of FriendID and DVDID.
To include the music DVDs in the ER diagram, we just need to add the Music_DVD
entity, and the Borrow relationship can be connected to both the DVD and
Music_DVD entities.

In the relational schema, we have added Music_DVD as a separate entity and


included it in the Borrow relationship as a Foreign Key.

Question 2)
What role ER model plays in the Database Design Process?

Answer)
The ER model is a valuable tool in the database design process as it helps to:

1. Model the data requirements of an organization.


2. Identify the entities, attributes, and relationships in the data.
3. Validate the data requirements and identify any issues.
4. Provide a high-level view of the data and its relationships.
5. Facilitate communication of the data requirements to stakeholders.
6. Ensure consistency between the data requirements and the database
design.

Question 3)

What two courses of actions are available to a database designer when he


encounters multi valued attribute? Explain with an example of your own and
also discuss their advantages and disadvantages.

Answer)
When a database designer encounters a multi-valued attribute, there are two
courses of action available:

1. Convert the multi-valued attribute into a separate entity: In this approach,


the multi-valued attribute is separated into a separate entity and a
relationship is established between the original entity and the new entity.
This approach is suitable when the multi-valued attribute is an important
aspect of the data and needs to be modeled as a separate entity.

For example, let's say a database designer is designing a database for a


library. The library has books and each book can have multiple authors.
Instead of having a multi-valued attribute "Author" for the book entity, the
designer can create a separate entity "Author" and establish a relationship
between the two entities.

Advantages:
• This approach provides better data integrity as it allows for separate
attributes for each value of the multi-valued attribute.
• It allows for easier querying of data as the multi-valued attribute is now a
separate entity.
• It provides a better representation of the data and its relationships.

Disadvantages:
• This approach can result in more complex data relationships and may
result in a larger number of tables in the database.
• It may also result in increased data redundancy.

2. Convert the multi-valued attribute into multiple single-valued attributes:


In this approach, each value of the multi-valued attribute is represented as a
separate single-valued attribute. This approach is suitable when the multi-
valued attribute has a limited number of values.

For example, let's say a database designer is designing a database for a sports
team. The team has players and each player can have multiple positions.
Instead of having a multi-valued attribute "Position" for the player entity, the
designer can create separate single-valued attributes such as "Position1",
"Position2", etc.

Advantages:
• This approach is easier to implement and results in a simpler database
schema.
• It eliminates the need for additional entities and relationships.

Disadvantages:
• This approach may result in data redundancy as the same data may be
repeated for each value of the multi-valued attribute.
• It may also result in data inconsistencies as data may not be entered for
all values of the multi-valued attribute.
• It may not provide a clear representation of the data and its
relationships.

The choice between the two courses of action depends on the specific
requirements of the database and the nature of the multi-valued attribute. The
database designer must weigh the advantages and disadvantages of each
approach and make the best decision for the specific situation.
Question 4) Define redundancy with respect to data storage. How can the
database approach help in controlling redundancy?

Answer)

Redundancy in data storage refers to the repeated storage of the same data in
multiple places. This occurs when the same information is stored in multiple
records or tables, leading to a waste of storage space and potential
inconsistencies in the data.

The database approach can help in controlling redundancy in several ways:

1. Normalization: Normalization is the process of organizing data in a


database to minimize redundancy and dependency. By normalizing data,
the database designer can eliminate redundant data and ensure that the
data is stored in a consistent and efficient manner.
2. Use of Primary Keys: The use of primary keys helps in controlling
redundancy by ensuring that each record in the database has a unique
identifier. This helps to avoid duplicates and inconsistencies in the data.
3. Referential Integrity Constraints: Referential integrity constraints are
rules that ensure that data entered in the database is consistent and
correct. For example, a referential integrity constraint can be used to
ensure that a foreign key value in a related table exists in the referenced
table.

4. Use of Views: A view is a virtual table that is derived from one or more
existing tables. By using views, the database designer can avoid the need
to store redundant data and ensure that the data is displayed in a
consistent manner.

By using these techniques, the database approach can help in controlling


redundancy in data storage and ensure that data is stored in an efficient and
consistent manner.

Question 5)
The Hudson Engineering Group (HEG) has contacted you to create a
conceptual model whose application will meet the expected database
requirements of the company’s training program. The description of the
operating requirement is given below The HEG has 12 instructors and can
handle up to 30 trainees per class. HEG offers five advanced technology
courses each of which may generate several classes. If a class has fewer than
10 trainees, it will be cancelled. Therefore, it is possible for a course not to
generate any classes. Each class is taught by one instructor. Each instructor
may teach up to two classes or may be assigned to do research only. Each
trainee may take up to two classes per year. Draw the ER diagram for this
situation. (i) Identify the entities. Take suitable attributes for each one of them.
(ii) Identify relationships between/among entities.
(iii) Specify the cardinality constraints, participation constraints and min, max
constraint for each relation.
(iv) Specify the assumptions made if any

Answer)

ER Diagram:

i) Entities:

1. Instructor - identified by instructor ID, with attributes such as name,


phone number, and research status (yes/no).
2. Trainee - identified by trainee ID, with attributes such as name, phone
number, and classes taken (up to 2 per year).
3. Course - identified by course ID, with attributes such as course name,
description, and number of classes generated.
4. Class - identified by class ID, with attributes such as course ID, instructor
ID, start date, and number of trainees.

(ii) Relationships:

1. Instructor teaches Class - indicates the instructor assigned to teach each


class.
2. Trainee takes Class - indicates the trainee enrolled in each class.
3. Course generates Class - indicates the course that generates each class.
4. Instructor instructs Trainee - indicates the instructor assigned to teach
each trainee.

(iii) Cardinality Constraints:

1. Instructor teaches Class - 1:N (1 instructor can teach multiple classes but
each class is taught by only 1 instructor)
2. Trainee takes Class - N:M (multiple trainees can take a class, and each
trainee can take multiple classes)
3. Course generates Class - 1:N (1 course can generate multiple classes, but
each class is generated by only 1 course)
4. Instructor instructs Trainee - 1:N (1 instructor can teach multiple trainees
but each is trainee can be taught by only 1 instructor)

(iv) Participation Constraints:

1. Instructor teaches Class - Total participation. Every instructor must be


assigned to teach a class or do research.
2. Trainee takes Class - Partial participation. Not all trainees need to take a
class.
3. Course generates Class - Partial participation. Not all courses will generate
a class.

(v) Min, Max Constraints:

1. Instructor teaches Class - Max 2 classes per instructor.


2. Trainee takes Class - Max 2 classes per year per trainee.
3. Class - Min 10 trainees per class, otherwise the class will be canceled.
4. Instructor instructs Trainee - Max 30 trainees per instructor.

Assumptions:
Each instructor has a unique instructor ID.

1. Each trainee has a unique trainee ID.


2. Each course has a unique course ID.
3. Each class has a unique class ID.

Question 6)
SHOP(Shop_No, Shop_name, Address, owner)
ITEM(I-No, I-Name)
SUPPLIED(I-No, C_No, Shop_No, Date, Price)
REQUIRES(C_No, I-No)
CUSTOMER(C_No, C_Name,C_Address)
SUPPLIED relation gives data about items supplied by a shop to a customer
and REQUIRES relation gives data about items required by a customer. Primary
keys of each relation are underlined.
(i) Write DDL statements to create these tables. Specify the Primary and
Foreign Key
constraints.
(ii) Write query statements for the following queries in SQL
(a). names of customers who have been supplied items of maximum
total
value.
(b). Names of customers who are supplied all the items from only "Jindal
Stores".
(c). List of shop owners who supplied some item to the address "Krishna
Nivas, MG Road"

Answer)

CREATE TABLE SHOP (


Shop_No INT PRIMARY KEY,
Shop_Name VARCHAR(100),
Address VARCHAR(100),
Owner VARCHAR(100)
);

CREATE TABLE ITEM (


I_No INT PRIMARY KEY,
I_Name VARCHAR(100)
);

CREATE TABLE SUPPLIED (


I_No INT,
C_No INT,
Shop_No INT,
Date DATE,
Price DECIMAL,
PRIMARY KEY (I_No, C_No, Shop_No),
FOREIGN KEY (I_No) REFERENCES ITEM (I_No),
FOREIGN KEY (C_No) REFERENCES CUSTOMER (C_No),
FOREIGN KEY (Shop_No) REFERENCES SHOP (Shop_No)
);

CREATE TABLE REQUIRES (


C_No INT,
I_No INT,
PRIMARY KEY (C_No, I_No),
FOREIGN KEY (I_No) REFERENCES ITEM (I_No),
FOREIGN KEY (C_No) REFERENCES CUSTOMER (C_No)
);

CREATE TABLE CUSTOMER (


C_No INT PRIMARY KEY,
C_Name VARCHAR(100),
C_Address VARCHAR(100)
);

a.
SELECT C_Name
FROM CUSTOMER
WHERE C_No = (SELECT C_No FROM SUPPLIED GROUP BY C_No ORDER BY
SUM(Price) DESC LIMIT 1);

b.
SELECT C_Name
FROM CUSTOMER
WHERE NOT EXISTS (
SELECT I_No
FROM ITEM
WHERE NOT EXISTS (
SELECT I_No
FROM SUPPLIED
WHERE I_No = ITEM.I_No AND Shop_Name = 'Jindal Stores' AND
CUSTOMER.C_No = SUPPLIED.C_No
)
);

c.
SELECT Owner
FROM SHOP
WHERE EXISTS (
SELECT I_No
FROM SUPPLIED
WHERE SHOP.Shop_No = SUPPLIED.Shop_No AND C_Address = 'Krishna Nivas,
MG Road'
);

You might also like