DBMS Interview Questions
This page consists of DBMS interview questions and answers.
A super key is a set of columns that can uniquely identify a row in a table.
Following is a simple customer table.
Note! Every customer gets a unique customerid and has a unique email address.
Following are some of the superkeys for the above customer table that can uniquely identify a row in the table.
A candidate key is a set of minimum number of columns that can uniquely identify a row in a table.
There can be more than one candidate key for a given table.
Value of a candidate key is unique and non-null value for all tuple (rows).
Following are some of the candidate key for the customer table that can uniquely identify a row in the table.
A candidate key can have one colume and it can also have multiple columns.
A candidate key with multiple columns is called a composite candidate key.
Following are some of the composite candidate key for the customer table that can uniquely identify a row in the table.
A primary key is one of the candidate key that is selected to uniquely identify rows of a table.
There can be more than one number of candidate keys for a given table and it is upto the architect to choose any one of the candidate key and make it the primary key.
We have selected customerid as the primary key for the customer table as it can uniquely identify a row in the table.
All candidate keys that are not the primary key are called the alternate keys.
A foreign key is an attribute of a table that will take only those values that are present in an attribute of other table.
Following is the customer_order table.
In the above table the customerid attribute is the foreign key in the customer_order table.
The customerid column of the customer_order table will take only those values that are present in the customerid column of the customer table.
Primary key column of a table is supposed to have only unique values.
Foreign key column of a table points at the primary key column of some other table. So, it is possible to have more than one row having the same value.
In the above customer_order table the foreign key column customerid has same value c5 appearing twice.
For an table there can only be ONE Primary key but the table can have multiple unique constraint.
Primary key can't have NULL value whereas, unique constraint can have NULL value.
Primary key is a unique contraint of a table.
SQL or Structured Query Language is a standardised query language that allows us to access and manage databases.
Have fun learning :-)
Copyright © 2014 - 2020 DYclassroom. All rights reserved.