Hello friends, welcome to Gate Smashers The topic is concept of Super Keys So many students has requested that make a video on this topic once So here I am going to cover the whole concept with numerical example possible, I am bringing that video here. So first of all, let's start with the concept super key A super key is the combination of all posible attributes Which can uniquely identified two tuples in a table. So here, first of all, Let me tell you that the candidate key is mostly used.
If we talk about whole DBMS, So the concept of primary key and candidate key is mostly used. So what is the candidate key? Whatever uniquely identify we have, means the set of all keys Which can uniquely identify to any two tuples.
that we called the candidate key. But with that candidate key, We add any attribute that becomes super key like i am taking here a simple example. If we have a table, student table in which we have a roll number.
name and age. There are three attributes. Now if given here Let say that roll number is a candidate key Roll number is a candidate key.
There is only one candidate key because the candidate key can be multiple. So what do we have the candidate key? Roll number.
So if the roll number is the candidate key, then it can uniquely identify any two tuples If along with the roll number, Roll number itself a candidate key and We can also called it super key. But with the roll number if I add any attributes, let's say with the roll number, I add the name. If I add age with the roll number or add all the three, roll number, Name, and age.
So what will this whole one become, super key, What will it become, super key, What is it, super key. Very simple concept. Candidate key is minimal that means the least.
So what is the lowest, roll number then this is the candidate key. You can also call it super key. But with that if you are adding any element, What will it become?
Super key. But if I ask here, Name and Age Combinedly can be a super key? No.
Super key does not mean that if you add any two or three elements then it is super key, No. What should be at least in the super key, Candidate key. There is no candidate key in name and age.
Candidate key is the roll number. The roll number should be there, you can add anything with it, that is super key. So, infact what can we say?
Super set of any candidate key is known as super key. So here we have Many times numerical questions come, I am discussing numerical question with you that we are given a table, R. In which we have A1, A2, A3 Upto AN Number of Attributes.
How many super keys are possible? If A1 is a candidate key means we have this table in which there are N numbers of elements. So it is given that A1 is a candidate key.
What do we have to do now? Let' say if if nothing is given and if take its power set. Power set means how many possible subset is possible here.
If we have A1, A2, A3. Let's say, we have three elements. What we do in power set, either we consider A1 or we don't.
will consider or not, means we have two choices for each attributes. What are the two choices, either you take A1 or don't take it. If you take A1, then let's say A1, A2 A1, A3, A1, A2, A3.
If you don't take A1 then let's say, A2, A3, in this way. There are two choices each here. So, How much the total number of possibilities?
But if we talk about, in this question, in this point, that A1 is a candidate key. Means it is given that in this whole table It means, A1 will come in every set, now whatever subset you are making. A1 is compulsory in it.
You can put A2 with A1. Let's say A1 is alone, put A2 with A1, put A3 with A1, put A4 with A1. We have N numbers of elements.
Or make of three A1, A2, A3. Make of four, but A1 will definetly come. So we have, means if we have to remove it, how many elements are left?
A1 will come. So, How many are the rest of the elements? N - 1 So how many options do we have for these N-1 elements, how much choices do we have?
So there are still two choices, even if you take A2 or not, take A3 or not, take A4 or not. But you will have to take A1. So how much will it come?
2n-1 So if it is given that A1 is a candidate key then, how many super keys are possible? 2 n - 1 Next If we talk about the second point. This will make you more clear here.
If we talk about the second point, that A1 and A2 Both are candidate key. It is given that in this table in which has N number of attributes, It has two candidate keys, A1 and A2 So how will you make it? A1 A1, A2.
A1, A2, A3. A1, A2, A3, A4 make as many as you want. How many possibilities are there?
Just now I told that if we are taking A1 alone, then you'll have consider A1. But for rest of the attributes, You will have two choices each, whether you consider or not. How many possibilities are there?
2 n-1 What do we have for another candidate key? A2 So how many possities are there for A2 as well? 2 n-1 So what will be the total?
2 n-1 + 2 n-1 But there is an another important point here which is, If we take A1 alone, then A1, A2 will be made in this way. What will happen if we carry A2 alone? Let's say A2 A2, A1.
A2, A1, A3 A2, A3, A1 Make whatever you want, make as you wish What's my main point here? There will be some sets common here. Look at this set.
And this one are same because there is a commutative property here, either say A1, A2 is a candidate key or say A2, A1 is a candidate key, it's a same thing. Here you will find common in a lot of places. So you have to take out those common.
So what will be common? Common will be in which A1 and A2 will definitely come. Means, sets that containing A1 and A2, sets that containing A1 and A2.
So how many will they be? If we say, in every set, A1& A2 must come together. So 2 n-2 choices are there, because we fixed two.
Minus as much as you're fixing. Let's say, you have fixed two, A1 and A2. How many left?
n-2 You have fixed three, A1, A2, A3 will definitely come. So how many left? 2 n-3 So just this is the way you have to do it.
so how many are there with A1 alone? 2 n-1 How many are there with A2 alone? 2 n-1 Add both of them but what to minus?
2 n-2 This is the actual answer. In this way, many times you get questions in the UGC NET and GATE. The concept of super key is very simple.
But if you get a question in this way, many times the students becomes confused. Let me tell you a little more about the last point. If we see another question, Let's say A1, A2 and A3, A4 In this way if given to us, There are two candidates keys.
And the candidate key is composite, means a candidate key consists of two, A1 and A2. So if we talk about this table which has these numbers of elements. How many possibilities do you have by combining A1, A2?
How many sets can you make? How many power set? 2 n-2 I just told You the reason that A1 and A2 will definitely come But from A3 to AN, you have two choices, so how many elements left?
2 n-2 Similarly if we say If we have A3 and A4 are candidate key, then how much super keys ? 2 n -2 So what will be the total? 2 n-2 + 2 n-2 But here too there is the same concept, Many candidate keys will be, you will have many super keys, which will be common It will be in both.
Let's say, A1, A2, A3 will also be in it. A1, A2, A3, A4 will also be in it A1, A2, A3, A4 will also be in it. So that you have to minus it, how much will it come?
What is the common of the four? means such subset in which these four are there, how many they will be? how many will be fixed?
Do minus four, 2 n-4 That's it. So this is all about the concept of super keys. So guys, If you like this video, then please like and share it as much as possible.
And please subscribe my channel. Thank you.