Keys
Question 1 |
Consider the following statements S1 and S2 about the relational data model:
S1: A relation scheme can have at most one foreign key.
S2: A foreign key in a relation schema R cannot be used to refer to tuples of R.
Which one of the following choices is correct?
S1: A relation scheme can have at most one foreign key.
S2: A foreign key in a relation schema R cannot be used to refer to tuples of R.
Which one of the following choices is correct?
S1 is false and S2 is true. | |
Both S1 and S2 are false. | |
Both S1 and S2 are true.
| |
S1 is true and S2 is false. |
Question 1 Explanation:
- A database table may have more than one foreign key, and each foreign key can have a different parent table. Hence, the statement I is incorrect.
- A foreign key is a set of attributes in a table that refers to the primary key of another table or to the primary key of the same table (self-referential table). Hence, the statement II is also incorrect.
Question 2 |
Consider the following database table:
Create table test( one integer, two integer, primary key(one), unique(two), check(one >= 1 and <= 10), check(two >= 1 and <= 5))
How many data records/tuples atmost can this table contains?
Create table test( one integer, two integer, primary key(one), unique(two), check(one >= 1 and <= 10), check(two >= 1 and <= 5))
How many data records/tuples atmost can this table contains?
5 | |
10 | |
15 | |
50 |
Question 2 Explanation:
Attribute "one" can have values:
1,2,3,4,5,6,7,8,9,10
Attribute "two" can have values:
1,2,3,4,5
Since "one" is given as the primary key so it can't have duplicates or null value. And "two" is given as unique key so it also can't have null or duplicate values.
So the number of rows in table will depend on the attribute having minimum number of values i.e "two" here. So the number of rows in table "test" are 5.
1,2,3,4,5,6,7,8,9,10
Attribute "two" can have values:
1,2,3,4,5
Since "one" is given as the primary key so it can't have duplicates or null value. And "two" is given as unique key so it also can't have null or duplicate values.
So the number of rows in table will depend on the attribute having minimum number of values i.e "two" here. So the number of rows in table "test" are 5.
Question 3 |
A primary key for an entity is
A candidate | |
Any attribute
| |
A unique attribute
| |
A super key |
Question 3 Explanation:
A primary key for an entity is a candidate key.
Question 4 |
A super key for an entity consists of
one attribute only
| |
At least two attributes
| |
at most two attributes
| |
one or more attributes
|
Question 4 Explanation:
Super key is a set of attributes of a relation schema upon which all attributes of the schema are functionally dependent. It can consist of one or more attributes.
For example : Consider a relation R(A,B,C,D) where “A” is the candidate key of “R” then Superkeys of “R” will be {A,AB, AC, AD, ABC, ABD, ACD, ABCD}.
For example : Consider a relation R(A,B,C,D) where “A” is the candidate key of “R” then Superkeys of “R” will be {A,AB, AC, AD, ABC, ABD, ACD, ABCD}.
There are 4 questions to complete.
