Type of Key Used In MS SQL

What is a Composite Key ?

A Composite primary key is a type of candidate key, which represents a set of columns whose values uniquely identify every row in a table.

What is a Composite Primary Key ?

A Composite primary key is a set of columns whose values uniquely identify every row in a table. What it means is that, a table which contains composite primary key will be indexed based on the columns specified in the primary key. This key will be referred in Foreign Key tables.

What is a Foreign Key ?

When a "one" table's primary key field is added to a related "many" table in order to create the common field which relates the two tables, it is called a foreign key in the "many" table.

For example, the salary of an employee is stored in salary table. The relation is established via foreign key column “Employee_ID_Ref” which refers “Employee_ID” field in the Employee table.

What is a Unique Key ?

Unique key is same as primary with the difference being the existence of null. Unique key field allows one value as NULL value.

What is a constraint?

Constraint can be used to specify the limit on the data type of table. Constraint can be specified while creating or altering the table statement. Sample of constraint are.

NOT NULL.
CHECK.
DEFAULT.
UNIQUE.
PRIMARY KEY.
FOREIGN KEY.

Differentiate between a HAVING CLAUSE and a WHERE CLAUSE.

HAVING CLAUSE

* HAVING CLAUSE is used only with the SELECT statement. 
* It is generally used in a GROUP BY clause in a query. 
* If GROUP BY is not used, HAVING works like a WHERE clause.

WHERE Clause

* It is applied to each row before they become a part of the GROUP BY function in a query.

Post a Comment

Post a Comment (0)

Previous Post Next Post