Sunteți pe pagina 1din 3

CS614 Assignment 1 solution

Mc180400574

Question No. 1
Consider the following schema related to a Social Media website named as ‘userPosts’. You
have to perform following tasks related to the provided schema:

1- Identify appropriate keys for following structure (Primary and/or foreign key(s))

Answer:

Primary key in userData will be uerID and foreignKey in PostData will be user
ID and primary Key in PostData will be Posted.

2- Convert this schema into 2 NF


userPosts (userID, userName, password, address, postId, postDate, postContent)

There will be two tables


1. User table
2. Post table

User table :

User Id (P-K) UserName Password Address


1 Kashif Kashif 786 16 R Rarah
Islamgarh
2 Usman Usman 859 18-B G Block
Islamgarh Colony
3 Asad Asad 123 15 A Block
Islamgarh Colony
Post Table :
Post Id (p-K) postdate PostContent UserId(F-K)
101 16/12/19 I am a student of 1
virtual University . I
am doing MCS.
102 17/12/19 I am student of Must 2
University. I am
doing BS IT.
103 18/12/19 I am a software 3
Engineer.I am
currently doing job.

Question No. 2
Consider the following schemas relevant to a hotel booking website. You are required to De-
Normalization the given schemas using Collapsing Tables Technique.

roomVisitor (roomID, visitorCNIC, dateTime)

roomCharges (roomID, spentDays, roomRent)

De-Normalization

Room Visitor:
RoomeID visitorCNIC Date and Time
1 452-16-6666666 25/09/13, 6:20am
2 452-18-8888888 10/09/13 ,8:40pm
3 452-13-3333333 12/09/13 ,5:30pm
Room Charges:

roomID spentdays roomRent


1 4 3000
2 3 2500
3 2 2000

De-Normalization

Roomed visitorCNIC dateTime spentDays roomRent


1 452-16-6666666 25/09/13, 6:20am 4 3000
2 452-18-8888888 10/09/13, 8:40pm 3 2500
3 452-13-3333333 12/09/13, 5:30 2 2000

S-ar putea să vă placă și