Skip to content
Home » Structured Query Language » SQL Keys

SQL Keys

Keys In SQL

Keys :-

It is an attribute which identifies the record/ tuple uniquely.

Keys play an important role in the relational database.

Candidate keys :-

It is an combination of one or more attributes which is used to identify records/ tuple uniquely. Except for the primary key, the remaining attributes are considered a candidate key. The candidate keys are as strong as the primary key.

Primary key :-

It is a candidate key which is selected unique identification of type, which can not have duplicate values or null values. For each entity, the primary key selection is based on requirements and developers.

Primary & Foreign key

Alternate key :-

Alternate key are the remaining keys which are not selected for primary key or Remaining candidate keys other than primary key.

Composite / Compound key :-

Set of more than one attribute which identifies tuple uniquely.

Super key :-

Super key is the super set of candidate keys.

Foreign key :-

It is a key used to establish connection between tables. It is a primary key of another table used to establish association between two entities ( Tables ). Every employee works in a specific department in a company, and employee and department are two different entities. So we can’t store the department’s information in the employee table. That’s why we link these two tables through the primary key of one table.

Primary & Foreign key

Parent key :-

It is a either primary key or unique key in parent table of referential constraint.

Surrogate key :-

It is a type of primary key which used a uniquely generated value. It should not have a business value and it should never change.

 

Sql Constraints

  1. Constraints are the rules that can be apply on the data in the table.
  2. These rules are applied on the data at time of storing into table.
  3. Following are the SQL contains
    1. Not Null: The values will never be null. Null values cannot insert into column.
    2. Unique: All values from the column will be unique and duplicate values are not allowed
    3. Primary Key: It is a combination of NotNull and Unique. By Making any column as Primary Key internally index will created for the faster search. Also This primary key column can be use as a foreign key to relate multiple table with each other.
    4. Foreign Key: The values can be null and can be duplicate, these values will be linked with another table primary key.
    5. Check: To Set the condition on the Data like range check, Data list check.
    6. Default: To set the default value for the column, By default the default values will be null in the SQL.

 

Join Telegram : Click Here

 

All Full Stack Java Study Material

 

Structured Query Language

 

Job’s For Fresher

 

Share This Information To Your Friends and Your College Group’s, To Help Them !