Total Page Preview:   000000000321

What is super key in SQL in English and Hindi

 

Super key in SQL in English

In SQL, a super key is a set of one or more columns in a table that can uniquely identify each row in the table. Unlike a candidate key, a super key may contain redundant or unnecessary columns, which means it may not be the minimal set of columns that can uniquely identify each row.

Here's an example of a super key in SQL:
Let's say we have a table named "customers" with columns for customer ID, first name, last name, email address, and phone number. We want to ensure that each row in the table can be uniquely identified by either the customer ID or the email address. However, we also want to include the first name and last name columns in our key, even though they may not be strictly necessary:
In this example, we've defined the customer ID as the primary key of the table using the "pk_customers" constraint. We've also defined a super key using the "sk_customers" constraint, which includes the customer ID, email, first name, and last name columns.
 
While the customer ID and email columns are necessary for uniquely identifying each row, the first name and last name columns are not strictly necessary. However, including them in our super key means that we can still uniquely identify each row based on the customer's full name, in addition to their customer ID or email address.
It's important to note that a super key may not be the most efficient or optimal way to uniquely identify each row in a table. In general, it's best to use the minimal set of columns necessary to create a candidate key or primary key, in order to optimize database performance and storage.
 
 
 
 
Super key in SQL in Hindi
SQL mai, super key ek aisa set hota hai jismein ek ya ek se adhik columns shamil hote hain jo table ke har row ko uniquely identify kar sakta hai. Ye candidate key se alag hota hai kyunki isme redundant aur unnecessary columns shamil ho sakte hain, jisse ki ye minimal set of columns nahi hota jo har row ko uniquely identify karta hai.
Neeche ek SQL example diya gaya hai jismein super key ka use kiya gaya hai:
Maan lijiye humare paas ek "employees" table hai jismein columns hai employee ID, first name, last name, email address, aur department ke liye. Hum chahte hain ki har row ko unique identify kiya jaye to hum employee ID aur email dono columns ko super key ke roop mein use karenge, saath hi first name aur last name bhi shamil karenge:
 
 
Is example mein humne "employees" table create kiya hai jismein paanch columns hai. Pehla column employee ID hai jo humne primary key set kiya hai. Dusra column employee ka first name hai, teesra column employee ka last name hai. Chautha column employee ka email address hai aur paanchva column employee ka department hai.
 
Humne employee ID aur email dono columns pe super key constraint bhi add kiya hai, jisse ki har employee ko unique identify kiya jaa sake. Iska matlab hai ki har row mein ya to employee ID unique hoga ya phir email unique hoga.
 
Humne super key mein first name aur last name bhi shamil kiya hai, jo ki redundancy create karta hai kyunki hum employee ko employee ID ya email address ke dwara hi uniquely identify kar sakte hain. Lekin super key ke roop mein, hum first name aur last name columns ko bhi shamil karna chahte hain taki hum employee ko naam ke adhaar pe bhi search kar sake.
 
Yeh ek example hai jismein super key ka use kiya gaya hai, lekin generally, hum candidate key ya primary key ke liye minimal set of columns hi use karna prefer karte hain taki database performance aur storage ko optimize kiya ja sake.

 

 

 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: