Showing posts with label Minimal cover. Show all posts
Showing posts with label Minimal cover. Show all posts

Monday, July 23, 2018

Relational model in DBMS Multiple choice questions with answers

Relational model in DBMS Multiple choice questions with answers

Multiple Choice Questions 30:

1. Which one of the following is correct?
a) Each candidate key is a primary key
b) Each primary key is a foreign key
c) Each foreign key must refer a primary key of a relation.
d) Each foreign key refers a candidate key in a relation.
Answer:
d) Each foreign key refers a candidate key in a relation.
Foreign key attribute refers attribute that contains unique values. It need not be the primary key always.

2. The value of an attribute in a table may be NULL because,
a) the value is not known
b) the value does not exist
c) the value is not applicable
d) all of the above
Answer:
d) all of the above.
NULL refers to all the options a, b, and c.

3. Consider a relation office with the following schema;

Office(Cabin_no, Room_no, Phone)

Room number is unique. Each room consists of approximately 20 cabins and each cabin number is unique with respect to room number. The same cabin number may be used in different rooms. Each room has unique phone number.

Which of the following is correct?
a) Room_no is a candidate key
b) Phone is a candidate key
c) (Cabin_no, Phone) and (Cabin_no, Room_no) are the candidate keys.
d) (Room_no, Phone) and (Room_no, Cabin_no) are the candidate keys.
Answer:
c) (Cabin_no, Phone) and (Cabin_no, Room_no) are the candidate keys.
Room_no is unique and each room has 20 cabins hence, retrieving data with Room_no as key will end up in at least 20 records. The same is applicable for Phone.
Cabin_no is unique for each room[or phone]. So, (cabin_no, phone) or (cabin_no, room_no) can uniquely identify records.

4. Consider the following schema of relation R;

R (A, B, C)

Attributes A, B, and C are all unique valued attributes. Which of the following is TRUE for R?
a) A is a candidate key for R
b) B is a candidate key for R
c) (A, C) is a super key for R
d) all of the above
Answer:
d) all of the above
As all attributes are unique valued attributes, each one of them is a candidate key on its own. Also, the combination of candidate keys cannot form another candidate key but a super key.

5. Which of the following is usually chosen as a primary key for a relation.
a) A candidate key that is composite
b) A super key
c) A candidate key that is minimal
d) All of the above
Answer:
c) A candidate key that is minimal
A candidate key that is composite can also be chosen as primary key. But in practice people usually prefers a minimal candidate key, that is, a candidate key that has minimal number of attributes. For example, if in a relation R(A, B, C), A is a candidate key and (B,C) is another candidate key we prefer A as the primary key though (B, C) can also act as a primary key.

***********



Go to Advanced DBMS Concepts page




multiple choice questions in relational model of DBMS
MCQs in relational model
MCQ about super key, candidate key and primary key
relational data model in database
solved quiz questions with answer in relational model

Saturday, February 24, 2018

Find minimal cover/canonical cover in a set of FDs

Find minimal cover/canonical cover in a set of given functional dependencies


Question:
For a relation schema R = (A, B, C, D, E), consider the following set of functional dependencies;
F = {A BC, CD E, B D, E A}
Using the functional dependencies compute the canonical cover Fc.

Solution:
Minimal cover:
Definition 1:
A minimal cover of a set of FDs F is a minimal set of functional dependencies Fmin that is equivalent to F. There can be many such minimal covers for a set of functional dependencies F.
Definition 2:
A set of FDs F is minimum if F has as few FDs as any equivalent set of FDs.


Follow these steps to find the canonical (minimal) cover;
1. Decompose each functional dependency in F to have singleton (single) attribute on the Right Hand Side (RHS).
2. Remove extraneous (redundant) attributes from Left Hand Side of each functional dependency.
[What is extraneous attribute? Refer here].
3. Find and eliminate redundant functional dependencies.

Let us apply the above said properties to F;
F = {A BC, CD E, B D, E A}

1. RHS of all functional dependencies should be singleton. To achieve this we decompose each functional dependency that has two or more attributes in their RHS. We get the following set of functional dependencies F1;
F1 = {A B, A C, CD E, B D, E A}

2. Remove extraneous (redundant) attributes. This is applicable only for those functional dependencies that have two or more attributes on its LHS.
We need to check whether or not an attribute/set of attributes of LHS of a functional dependency is redundant or not. For checking this, we have to find the closure of each individual LHS attribute of each FD that has two or more LHS attributes.
With this property we have only one FD, CD E. We need to check whether C alone or E alone can find E uniquely.
C+ = C by reflexivity rule
D+ = D by reflexivity rule
From this we found that either C or D alone cannot determine the value of E. Hence, the FD CD E does not have any extraneous attributes.
Hence, our F1 is as follows;
F1 = {A B, A C, CD E, B D, E A}

3. Eliminate redundant functional dependencies.
To find redundant FDs, we have to find whether the RHS of a FD can be determined using other FDs.
(i) Let us check first for FD, A B. To proceed, we forget , A B from F, and use only the remaining FDs A C, CD E, B D, E A of F. That is our F becomes F1 = {A C, CD E, B D, E A}
No FD have B on RHS. Hence, A B is not redundant.
(ii) Now check for A → C. can we find C using following FDs?
F1 = {A B, CD E, B D, E A}
A+ = ABD
B+ = BD
We are not able to determine C using F1. Hence, A C is not redundant.
If we repeat this for each FD in F, we found that none of them are redundant.

Hence our Fc is as follows;
Fc = {A → BC, CD → E, B → D, E → A} which is same as F in the question.

***********


Similar topics

How to find closure of set of functional dependencies?

How to find closure of attributes?

How to find canonical cover for a set of functional dependencies?

How to find extraneous attribute?




Go back to Question/QUIZ page




find canonical cover of F
what is minimal cover? how to find minimal cover
minimal cover solved exercise
find extraneous attributes
 





Sunday, February 11, 2018

Find the redundant extraneous attributes

Find the redundant (extraneous) attributes from the set of functional dependencies


Question:

Consider the relation STUDENT with the schema STUDENT(RegNo, Name, DOB, Age, Dept, Course, Semester, Grade) and set of functional dependencies F = {RegNo Name, RegNo DOB, RegNo DOB Age, RegNo Dept, RegNo Dept Course Semester Grade}. Find the attributes that are redundant in the given set F of functional dependencies.

Solution:

What is redundant attribute?
An attribute in the left hand side (LHS) of a functional dependency, especially if more than one attribute present in the LHS, is said to be a redundant (extraneous) attribute if the RHS attribute(s) can be determined with the help of other LHS attributes.

How to identify a redundant attribute?
If the RHS of the said functional dependency can be derived without one of the attributes on the LHS, using the other FDs of that relation, then that particular attribute is said to be redundant. For example, in AB → C the attribute B is redundant if closure of A can determine C.

Let us solve the given question;

We don’t need to check for redundant attributes in a FD (functional dependency) where the LHS attribute is only one. Hence, we can omit the following FDs.
RegNo Name,
RegNo DOB,
RegNo Dept,

(i) Now let us take the FD RegNo DOB → Age. To check either of the LHS attributes are redundant, we have to use the other attribute to derive the RHS.

Is DOB redundant?
To check, we have to find the closure of the other attributes. In this FD, RegNo is the only other attribute. Hence let us find the closure of RegNo.

(RegNo)+ = RegNo, Name, DOB, Dept, Age.

Observe from the closure that the attribute Age is part of the closure. Hence, DOB is redundant attribute. So we can remove DOB from RegNo DOB Age results in the FD RegNo → Age.

Now our F becomes { RegNo → Name, RegNo → DOB, RegNo → Age, RegNo → Dept, RegNo Dept Course Semester → Grade}

(ii) Now let us take the last FD RegNo Dept Course Semester → Grade.

Is Dept redundant?
(RegNo Course Semester)+ = RegNo, Name, DOB, Dept, Age, Course, Semester, Grade.

Result includes Grade. So attribute Dept is redundant and can be removed.
Now our F becomes { RegNo → Name, RegNo → DOB, RegNo → Age, RegNo → Dept, RegNo Course Semester → Grade}

(iii) Let us take the last FD given above, RegNo Course Semester → Grade.

Is Course redundant?
(RegNo Semester)+ = RegNo, Name, DOB, Age, Dept, Semester

The result does not include Grade. Hence, the attribute Course is not redundant. And our F does not change.

Is Semester redundant?
Find the closure of RegNo, Course.
(RegNo, Course)+ = RegNo, Name, DOB, Age, Dept, Course.

The result does not include Grade. Hence, the attribute Semester is not redundant. And our F does not change.

The final set of functional dependencies F is as follows;
F = { RegNo → Name, RegNo → DOB, RegNo → Age, RegNo → Dept, RegNo Course Semester → Grade}

***************


Go to - 1NF,    2NF,    3NF,    BCNF





Find the redundant attributes in a given functional dependency
How to remove redundant attributes
How to remove extraneous attributes
Find and remove redundant (extraneous) attributes
Normalize relational table by removing redundant attributes
How to eliminate extraneous attributes to find minimal cover


Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents

MageNet Ad

data recovery