Keys in a Relational model
Key is a fundamental concept in the relational model in which it provides the basic
mechanism for retrieving tuples within a database. It specifies how tuples within a given
relations are distinguished and expressed in terms of attributes.
Key can be a single attribute or a group of attributes, where the combination
may act as a key. These attribute values can uniquely identify the tuples and no two
tuples in a relation are allowed to have exactly the same value for all attributes.
For e.g. rollno in student table, cust_no in a customer table, ac_no in Acconunt
table etc.
Super key
Super Key is defined as a set of attributes within a table that can uniquely identify each
record within a table. Super Key is a superset of Candidate key
.Eg: In a customer table Cust_id, Loan_no , (Cust_id , Cust_name), (Cust_id,
Loan_no),(Cust_name,Loan_no )
In a student table rollno,(stud_name,address),phoneno
Candidate Key
Candidate keys are defined as the minimal set of fields which can uniquely identify each
record in a table. It is an attribute or a set of attributes that can act as a Primary Key for a table
to uniquely identify each record in that table. There can be more than one candidate key.
A candiate key can never be NULL or empty. And its value should be unique.
There can be more than one candidate keys for a table.
A candidate key can be a combination of more than one columns(attributes).
Eg: In the customer table Cust_id and Loan_no are candidate keys.
In the student table rollno and phoneno are candidate keys.
,Primary Key
Primary key is a candidate key that is most appropriate to become the main key
for any table. It is a key that can uniquely identify each record in a table.
• A Primary key is selected from a set of candidate keys.
• This is done by database admin or database designer.
• Two rows can't have the same primary key value
• The primary key field cannot be null.
• A table can have multiple candidate keys but only a single primary key.
Eg: in customer table Cust_id can be taken as primary key.
In student table rollno can be taken as primary key.
Alternate Key
The candidate keys which are not selected as primary key are known as secondary
keys or alternative keys.
• It is a column or group of columns in a table that uniquely identify every row in
that table.
• A table can have multiple choices for a primary key but only one can be set as
the primary key. All the keys which are not primary key are called an Alternate
Key.
Eg: In customer table Loan_no is alternate key.
In student table phoneno is the alternate key.
Foreign key
A foreign key is a key used to link two tables together. This is sometimes also called as
a referencing key.It is a column or a combination of columns whose values match a
Primary Key in a different table.
The relationship between 2 tables matches the Primary Key in one of the tables with a
Foreign Key in the second table.They act as a cross-reference between tables
, Relational Database Management System(RDBMS)
A Relational Database management System(RDBMS) is a database management
system based on the relational model introduced by E.F Codd. In relational model, data is
stored in relations(tables) and is represented in form of tuples(rows).
RDBMS is used to manage Relational database. Relational database is a collection of
organized set of tables related to each other, and from which data can be accessed easily.
Relational Database is the most commonly used database these days.
Relational database model, a table is a collection of data elements organised in terms of
rows and columns. A table is also considered as a convenient representation of relations. But a
table can have duplicate row of data while a true relation cannot have duplicate data. Table is
the most simplest form of data storage.
single entry in a table is called a Tuple or Record or Row. A tuple in a table represents
a set of related data.
A table consists of several records(row), each record can be broken down into several
smaller parts of data known as Attributes. For eg: An Employee table consist of four
attributes, ID, Name, Age and Salary.
• A RDBMS is an extension of a DBMS
Key is a fundamental concept in the relational model in which it provides the basic
mechanism for retrieving tuples within a database. It specifies how tuples within a given
relations are distinguished and expressed in terms of attributes.
Key can be a single attribute or a group of attributes, where the combination
may act as a key. These attribute values can uniquely identify the tuples and no two
tuples in a relation are allowed to have exactly the same value for all attributes.
For e.g. rollno in student table, cust_no in a customer table, ac_no in Acconunt
table etc.
Super key
Super Key is defined as a set of attributes within a table that can uniquely identify each
record within a table. Super Key is a superset of Candidate key
.Eg: In a customer table Cust_id, Loan_no , (Cust_id , Cust_name), (Cust_id,
Loan_no),(Cust_name,Loan_no )
In a student table rollno,(stud_name,address),phoneno
Candidate Key
Candidate keys are defined as the minimal set of fields which can uniquely identify each
record in a table. It is an attribute or a set of attributes that can act as a Primary Key for a table
to uniquely identify each record in that table. There can be more than one candidate key.
A candiate key can never be NULL or empty. And its value should be unique.
There can be more than one candidate keys for a table.
A candidate key can be a combination of more than one columns(attributes).
Eg: In the customer table Cust_id and Loan_no are candidate keys.
In the student table rollno and phoneno are candidate keys.
,Primary Key
Primary key is a candidate key that is most appropriate to become the main key
for any table. It is a key that can uniquely identify each record in a table.
• A Primary key is selected from a set of candidate keys.
• This is done by database admin or database designer.
• Two rows can't have the same primary key value
• The primary key field cannot be null.
• A table can have multiple candidate keys but only a single primary key.
Eg: in customer table Cust_id can be taken as primary key.
In student table rollno can be taken as primary key.
Alternate Key
The candidate keys which are not selected as primary key are known as secondary
keys or alternative keys.
• It is a column or group of columns in a table that uniquely identify every row in
that table.
• A table can have multiple choices for a primary key but only one can be set as
the primary key. All the keys which are not primary key are called an Alternate
Key.
Eg: In customer table Loan_no is alternate key.
In student table phoneno is the alternate key.
Foreign key
A foreign key is a key used to link two tables together. This is sometimes also called as
a referencing key.It is a column or a combination of columns whose values match a
Primary Key in a different table.
The relationship between 2 tables matches the Primary Key in one of the tables with a
Foreign Key in the second table.They act as a cross-reference between tables
, Relational Database Management System(RDBMS)
A Relational Database management System(RDBMS) is a database management
system based on the relational model introduced by E.F Codd. In relational model, data is
stored in relations(tables) and is represented in form of tuples(rows).
RDBMS is used to manage Relational database. Relational database is a collection of
organized set of tables related to each other, and from which data can be accessed easily.
Relational Database is the most commonly used database these days.
Relational database model, a table is a collection of data elements organised in terms of
rows and columns. A table is also considered as a convenient representation of relations. But a
table can have duplicate row of data while a true relation cannot have duplicate data. Table is
the most simplest form of data storage.
single entry in a table is called a Tuple or Record or Row. A tuple in a table represents
a set of related data.
A table consists of several records(row), each record can be broken down into several
smaller parts of data known as Attributes. For eg: An Employee table consist of four
attributes, ID, Name, Age and Salary.
• A RDBMS is an extension of a DBMS