02 RDD CG 2D

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

LESSON: 2D

EXPERIMENT

2D.1 Relational Database Design


Relational Database Design 2D.2
LAB EXERCISES

Exercise 1
Shopping Spree is a leading departmental store in New Jersey. The store has a
number of regular customers who purchase bulk items. The store also conducts
regular feedback sessions to analyze customer satisfaction levels. Jim Lewis, the
customer analyst of Shopping Spree has to make the E/R diagram to represent the
above situation and then map the E/R diagram to corresponding tables.

INSTRUCTOR NOTES

Solution

CUST- CUST- PROD-


NAME ADDRESS PROD-NO DESC
MODEL
CUST-
CODE
PRICE
m m
CUSTOMER PURCHASES PRODUCT

FEEDBACK-DATE
CUST- PURCHASE-
CODE DATE

PROD-NO

CUSTOMER

CUST_CODE CUST_NAME CUST-ADDRESS

2D.3 Relational Database Design


PRODUCT

PROD_NO PROD_DESC MODEL PRICE

PURCHASE

CUST_CODE PROD_NO PURCHASE-DATE FEEDBACK-DATE

Exercise 2
Steve Irving is the database designer of New Publications Library. The library has
three sections: Academics, Magazines, and Fiction. The higher-level entity is displayed
as follows:

OWNER LIBRARY LOCATION

PHYSICS SUSPENSE
BOOKS TIME
THRILLERS
MAGAZINE

Steve needs to draw the specialization diagram for the given entity.

Relational Database Design 2D.4


INSTRUCTOR NOTES

Solution

OWNER LIBRARY LOCATION

ACADEMICS MAGAZINES FICTION

PHYSICS TIME SUSPENSE


BOOKS MAGAZINE THRILLERS

Exercise 3
Don Allen is the sales supervisor of a departmental store. He needs to review the
weekly sales record of the store. The computer operator has created a table that
consists of all relevant fields. Don needs to normalize the table and form independent
tables that convey unique type of information.

Use the SALES DATA table to solve the problem.

2D.5 Relational Database Design


SALES DATA

C_ID C_Name Order Item Qty Rate Bill_No Bill_Amt Bill_Dt


_No

INSTRUCTOR NOTES

Solution
The given Sales Data table is already in 1 NF.
In this table, C_Name depends only on C_ID. Therefore, we need to create a separate
table, Customer as follows:
CUSTOMER

C_ID C_Name

Also, in the Sales Data table, Item, Qty, and Rate depend only on Order_No.
Therefore, we need to create a separate table, Order. This table will be as follows:
ORDER

Order_No Item Qty Rate C_ID

In addition, Bill_Amt and Bill_Dt depend only on Bill_No. Therefore, we need to create
another table, Bill as follows:

Relational Database Design 2D.6


BILL

Bill_No Bill_Amt Bill_Dt Order_No

Therefore after 2 NF, we have three tables, Customer, Order, and Bill as shown above.
Now, in the Order table, Rate depends on Item. Therefore, we need to create another
table Item as follows:
ITEM

Item_No Item Rate

Now, the Order table will become:


ORDER

Order_No Item_No Qty C_ID

Therefore, after 3 NF, the tables obtained are as follows:


CUSTOMER

C_ID C_Name

2D.7 Relational Database Design


ORDER

Order_No Item_No Qty C_ID

BILL

Bill_No Bill_Amt Bill_Dt Order_No

ITEM

Item_No Item Rate

Relational Database Design 2D.8


ADDITIONAL EXERCISES

Exercise 1
New Heights is a training institute that provides courses on various non-technical
subjects, like personality improvement and foreign languages. Tim, the database
designer at the institute, has made the following relation to represent the data about
students, batches, and modules covered in the batches.
STUD-ID: Student’s id (unique)
NAME: Name of student
BATCH-NO: Batch number (one student can belong to only one batch)
SLOT: Time and day during which the batch of students attends the class
MODULE: Module or subject (one batch will do several modules)
MARKS: Marks obtained in a module test
Tim now needs to simplify the above relation by normalizing it.

INSTRUCTOR NOTES

Solution
The table that comes from the given relation is:
STUDENT

STUD-ID NAME BATCH-NO SLOT MODULE MARKS

This table is in 1 NF.


In this table, SLOT is dependent on BATCH-NO and not on STUD-ID. Therefore, we get
the following tables when we normalize the tables to 2 NF.

2D.9 Relational Database Design


STUDENT

STUD-ID NAME BATCH-NO MODULE MARKS

BATCH

BATCH-NO SLOT

Now, in the STUDENT table, MODULE and MARKS depend only on STUD_ID.
Therefore, we need to create another table, MARKS to normalize the tables to 3 NF.
The MARKS table is as follows:
MARKS

STUD-ID MODULE MARKS

Now, the STUDENT table becomes:


STUDENT

STUD-ID NAME BATCH-NO

Relational Database Design 2D.10


As a result, after 3 NF, the tables obtained are:
STUDENT

STUD-ID NAME BATCH-NO

BATCH

BATCH-NO SLOT

MARKS

STUD-ID MODULE MARKS

Exercise 2
National Bank is located in Chicago. This bank has two types of customers, people and
organizations. These organizations can be business companies, nonprofit
organizations, churches, and government agencies. Mary Peterson is a database
designer at the bank. She has been asked to draw an E/R diagram that distinguishes
between the two types of customers. The bank wants to keep a record of the birth
dates of individual customers. For organizations, the bank wants to maintain
information about the type of organization and the contact person.

2D.11 Relational Database Design


INSTRUCTOR NOTES

Solution

CUST-CODE
CUST-
ADDRESS

CUSTOMER

ORGANIZATION
INDIVIDUAL

ORGANIZATION
CONTACT -TYPE
BIRTH-DATE PERSON

Relational Database Design 2D.12


HOME ASSIGNMENT

1. Which type of relationship is established when multiple students can enroll for
one course?
a. One-to-One
b. One-to-Many
c. Many-to-One
d. Many-to-Many

2. Which of the following types of relationship enables you to merge two tables
for faster access?
a. One-to-One
b. Many-to-One
c. One-to-Many
d. Many-to-Many

3. Which of the following specifies a key that is made up of more than one
attribute?
a. Primary key
b. Foreign key
c. Alternate key
d. Composite key

4. Which of the following keys is an attribute that is a candidate for the primary
key but is not the primary key?
a. Alternate key
b. Foreign key
c. Candidate key
d. Composite key

5. Which of the following is the result of taking the union of two or more lower-
level entity sets to produce a higher-level entity set?
a. Relationship
b. Specialization
c. Supertype

2D.13 Relational Database Design


d. Generalization

6. Normalization reduces redundancy using_______.


a. E/R diagrams
b. Primary and Foreign keys
c. Non-loss decomposition
d. Top-down approach

7. Which of the following causes update anomalies in a database?


a. Normalization
b. Entity relationships
c. Functional dependency
d. Redundancy

8. If attribute A in a relation is functionally dependent on attribute B, attribute B


is called a ___________.
a. Determinant
b. Candidate key
c. Composite key
d. Primary key

9. In which of the following normal forms every attribute in a row is functionally


dependent upon the whole key of the relation, and not a part of the key?
a. 1 NF
b. 2 NF
c. 3 NF
d. BCNF

10. In which of the following normal forms every determinant in a relation is a


candidate key?
a. 1 NF
b. 2 NF
c. 3 NF
d. BCNF

Relational Database Design 2D.14


INSTRUCTOR NOTES

Solutions
1. c
2. a
3. d
4. a
5. d
6. c
7. d
8. a
9. b
10. d

2D.15 Relational Database Design

You might also like