What do you understand by the term primary key?
Primary Key in a table identifies each and every row uniquely. Primary key should not allow null values and primary key could be assigned on only column or more than one column also.
Differentiate between primary key and unique key.
The major differences between Primary key and Unique key are
- Primary key does not allow null values where as unique key will allow null values.
- By default Primary key is created as clustered index whereas unique key is created as non-clustered index.
Illustrate different levels of data integrity in SQL Server.
- Entity Integrity: Entity Integrity ensures that there are no duplicate rows in a table.
- Domain Integrity: Domain Integrity enforces valid entries for a given column by restricting the type, the format, or the range of possible values.
- Referential integrity: Referential integrity ensures that rows cannot be deleted, which are used by other records.
What are the different constraints to maintain data integrity in SQL Server?
- Check constraints: Check constraints are useful to limit the range of possible values in a column. We could create check constraints at two different levels – Column-level check constraints are applied only to the column and cannot reference data in another other column where Table-level check constraints can reference any column within a table but cannot reference columns in other tables
- Default constraints: Default constraints enable the SQL Server to write default value to a column when user doesn’t specify a value.
- Unique constraints: A unique constraint restricts a column or combination of columns from allowing duplicate values.
- Primary key constraints: Primary key constraints will allow a row to be uniquely identified. This will perform by primary key on the table.
- Foreign key constraints: Foreign keys constraints will ensure that the values that can be entered in a particular column exist in a specified table.
2 Comments. Leave new
Well written.
informative…