0:01 foreign 0:07 welcome back in this presentation we are 0:10 going to see some solved questions in 0:12 the topic keys in rdbms let's step into 0:16 question number one the question is 0:18 which of the following is correct about 0:21 keys in tbms and the options are given 0:24 option A it is mandatory in tables 0:28 option b it can be changed frequently 0:31 option C it can be a set of one or more 0:35 columns that uniquely identify a record 0:38 and option D all of the above I request 0:42 you to pause this video for a while and 0:44 think about the right answer 0:47 I hope you are done and the right answer 0:50 for this question is option C key can be 0:53 a set of one or more columns or 0:56 attributes that uniquely identify a 0:58 record why option A is incorrect because 1:02 we may have a table or a relation which 1:05 may contain a key attribute or may not 1:07 contain a key attribute and hence we 1:10 can't say that it is always mandatory in 1:12 the table or relations at the same time 1:15 the column or attribute that is chosen 1:17 as a key will not be changed frequently 1:20 only in a very rare situation it can be 1:23 changed but generally key attributes 1:25 cannot be changed frequently and that is 1:28 why for question number one option C is 1:31 the right answer 1:32 we are done with question number one 1:34 let's now move on to question number two 1:37 and the question is referring to the 1:40 below table a table is given which 1:42 attribute is appropriate to be a key 1:45 attribute so we are given with the table 1:47 employee which contains attributes ID 1:50 which means employee ID name of the 1:53 employee Department salary and City and 1:57 we are required to find which attribute 1:59 in this list of five attributes can be 2:02 appropriate to be a key attribute let's 2:05 see the options the options are option a 2:08 ID option b name option C salary and 2:12 option D none of the above I request you 2:15 to pause this video for a while and 2:16 think about the right answer 2:19 and the right answer for this question 2:21 is option a ID 2:23 every employee will have an ID and this 2:26 will be unique throughout the 2:28 organization and that's why we are 2:30 preferring ID as the key attribute why 2:32 we are not preferring name as a key 2:34 attribute because many employees may 2:36 have the same name the same time many 2:39 employees may have the same salary 2:40 structure also and that's why the column 2:43 or attribute ID can be appropriate to be 2:46 a key attribute 2:48 we are done with question number two 2:50 let's now move on to question number 2:52 three the question is referring to the 2:55 below schema which attribute or 2:58 attributes is or are appropriate for 3:01 being a key attribute and the schema is 3:04 the student relation which contains the 3:06 attributes name date of birth age City 3:10 and zip code 3:12 and what are all the options option a 3:15 name option b name and date of birth 3:18 option C name and City and option D none 3:22 of the above please pause this video for 3:24 a while and think about the right answer 3:27 let's analyze the options in this case 3:30 name alone cannot be a key attribute 3:32 because we know multiple students may 3:35 have the same name and that's why this a 3:37 cannot be a key attribute and coming to 3:40 name and date of birth this is a 3:42 composite key where multiple columns or 3:44 attributes combine together to form a 3:46 key in this case the composite key name 3:49 plus date of birth May uniquely identify 3:51 a tuple but we can't guarantee hundred 3:54 percent there are chances that student 3:56 name and the same date of birth may also 3:58 exist in the same database and coming to 4:01 option C name plus City again there may 4:04 be more than one student with the same 4:06 name from the same city as well so I 4:08 would say this is also not appropriate 4:10 for being a key and option D none of the 4:13 above and the right answer for this 4:15 question is option D none of the above 4:17 because name name plus date of birth and 4:21 name plus City cannot uniquely identify 4:23 a tuple but to some extent name and date 4:26 of birth May uniquely add identify but 4:29 it actually depends on the database 4:31 we are done with question number three 4:33 and let's move on to question number 4:35 four the question is the minimal super 4:37 key is called as Dash key and the 4:40 options are option a primary key option 4:44 b foreign key option C candidate key and 4:47 option D alternate key and the right 4:50 answer for this question is option C 4:52 candidate key because candidate key is 4:54 the minimal set of attributes that can 4:57 uniquely identify a tuple in simple 4:59 terms a candidate key is a minimal super 5:02 key with no repeated data a Super Key 5:04 may contain extraneous attributes but 5:07 this candidate key is the minimal Super 5:09 Key also a table can have multiple 5:11 candidate keys but exactly one primary 5:14 key why am I not choosing primary key as 5:16 the right answer because a primary key 5:19 itself is a candidate key and why 5:21 foreign key is not considered because 5:23 foreign key are used for referential 5:25 integrity where it involves two tables 5:28 and coming to the last option the 5:30 alternate key the candidate key other 5:32 than the primary key is called an 5:34 alternate key say for example we may 5:36 have five candidate keys and one of the 5:39 keys will be chosen as the primary key 5:40 and the rest of the keys are called as 5:43 alternate keys 5:44 we are done with question number four 5:46 let's move on to question number five 5:48 the question is the subset of super key 5:51 is a candidate key under what condition 5:54 and the options are option A any subset 5:58 is a Super Key option b all subsets are 6:02 super Keys option C no proper subset is 6:06 a Super Key and option D none of the 6:08 above 6:09 I request you to pause this video for a 6:12 while and think about the right answer 6:15 I hope you are done to find the answer 6:18 for this question I'm gonna bring in the 6:20 same example which we had seen in the 6:22 last presentation we know what is a 6:24 candidate key a candidate key is a 6:26 minimal Super Key and we know what is a 6:29 Super Key it is the superset the all 6:31 possible keys in a relation and this is 6:34 the superset actually let's take an 6:36 example here I am gonna take an example 6:38 called name and phone number which is a 6:41 Super Key and this is also a candidate 6:43 key we know how to derive candidate key 6:45 from the super keys if you are not sure 6:47 I request you to watch my previous 6:49 lecture about keys in rdbms so when we 6:53 talk about this key name and phone 6:55 number now this is actually a set and 6:58 when we say this is a set Motorola 7:00 subset we can derive from the set name 7:03 alone and phone number alone so when we 7:05 say name alone and phone number alone 7:07 are separate subsets and this is from 7:10 this set when we create the subset from 7:13 this set name phone number combo then 7:15 name alone and phone number alone are 7:17 separate subsets I mean name alone is 7:20 one subset phone number alone in another 7:22 subset but actually name alone and phone 7:25 number alone are not keys at all and 7:28 that's why option A is invalid any 7:30 subset is a Super Key is not correct and 7:33 coming to option b all subsets are super 7:36 Keys obviously this is also invalid 7:39 because when any subset is a Super Key 7:41 is not valid then obviously all subsets 7:43 are super cases also not valid let's 7:46 take the same example name and phone 7:47 number name separately and phone number 7:49 separately are subsets 7:51 and obviously the subset name and the 7:54 subset phone number are not super keys 7:56 at all and that's why the option b all 7:58 subsets are super case is not correct 8:01 and coming to option C no proper subset 8:04 is a Super Key which is true you know 8:07 why let's take this example name SSN and 8:10 phone number when we take this as a set 8:12 name SSN and phone number we can have 8:15 multiple subsets for this name alone 8:17 name and SSN name and phone number can 8:20 you see name and phone number so what I 8:22 mean to say here is when I take this as 8:25 the subset 8:26 and we can see there is a Super Key or 8:28 superset which has additional attribute 8:31 when we take name SSN and phone number 8:33 we have name phone number here we have 8:35 additional attribute here so the right 8:37 answer in simple terms the subset of a 8:40 set cannot be the same set and candidate 8:43 keys are set from Super Key which cannot 8:46 be the whole of the superset so option C 8:49 is the right answer here and option D is 8:51 obviously not correct because option C 8:53 is already the correct answer so the 8:56 right answer for the question the subset 8:58 of super key is a candidate key under 9:00 what condition and the condition is no 9:02 proper subset is a Super Key we are done 9:05 with question number five let's move on 9:07 to question number six the question is 9:09 we can Define more than one primary key 9:12 in a single table 9:14 and this is a true or false question and 9:17 the right answer for this question is 9:19 false because we cannot Define more than 9:22 one primary key in a single table we may 9:25 have multiple candidate keys but one of 9:27 the candidate Keys only will be chosen 9:29 as a primary key and hence we can Define 9:32 only one primary key in a single table 9:35 we are done with question number six 9:37 let's move on to the last question the 9:39 question is which key is used to make 9:42 relationship between two tables and the 9:45 options are option a Super Key option b 9:48 candidate key option C primary key and 9:51 option D foreign key and it's very easy 9:54 to answer this question because when we 9:56 talk about two tables and the 9:57 relationship among two tables obviously 10:00 option D foreign key is used 10:03 and that's it guys I hope you liked this 10:05 video and thank you for watching 10:08 [Applause] 10:10 [Music] 10:17 thank you 10:18 [Music]