Understanding Questions For SQL Server & SQL Server Management Studio Part II


Primary Key :
  • A primary key is a field in a table which uniquely identifies each row/record in a database table. 

  • Primary keys must contain unique values.


Explain What is a Identity Column ?
  • Identity column of a table is a column whose value increases automatically. 

  • The value in an identity column is created by the server. 

  • A user generally cannot insert a value into an identity column.

  • Identity column can be used to uniquely identify the rows in the table.


How can I create One to Many relationship ?
  • In a one-to-many relationship, one record in a table can be associated with one or more records in another table.

How can I create Primary Key & Foreign Key relationship ?
  • In a foreign key reference, a link is created between two tables when the column or columns that hold the primary key value for one table are referenced by the column or columns in another table. 

  • This column becomes a foreign key in the second table.


Are NULLs allowed in Foreign Key ?
  • Yes, it can be NULL. 

  • A Foreign key simply requires that the value in that field must exist first in a different table. 

  • Null by definition is not a value.


How can we create Composite Key ?
  • Composite key is a key which is the combination of more than one field or column of a given table.


How to write a simple SQL with Where Clause ?
  • The WHERE clause is used to filter records.

  • It is used to extract only those records that fulfill a specified condition.

How to Select specific Column in Select ?
  • The column names that follow the select keyword determine which columns will be returned in the results.


What is an ALIAS in SQL ?
  • SQL aliases are used to give a temporary name.

  • An alias is created with the AS keyword.


Explain the Difference between Inner vs Left vs Right ?
  • INNER JOIN : Returns records that have matching values in both tables.

  • LEFT JOIN : Returns all records from the left table, and the matched records from the right table.

  • RIGHT JOIN : Returns all records from the right table, and the matched records from the left table.

Comments

Popular posts from this blog

Function In SQL Server Part VIII

Learn Garbage Collection Day 21

Understanding C Sharp Day 18