SQL-Constraints

Constraints in Database

Six types of constraints

  1. Primary Key Constraint (Candidate Key)
  • Does not allow the entry of Null values
  • Does not allow the entry of duplicate values
  • Primary Key is the column that uniquely identifies a Row in a table
  1. Unique Key Constraint
  • Does not allow the duplicate values
  • Does allow the Null values
  • Unique Key is the column that identifies a row in the table
  1. Foreign Key Constraint (Integrity Constraint)
  • FK is the column that is derived from the primary key column of the previous table
  1. Default Constraint
  • Boolean Values (True/False, M/F)
  1. Not Null Constraint
  • Does not allow the entry of Null values
  1. Check Constraint
  • A conditional statement with aggregate functions
  • Where condition and Having clause together
  • Having clause will be used for Aggregate functions

JOINS

  1. Equi Join (-) = sign 

          Two tables: (Employee and Attendance)

          (both tables have columns empno)

          Select * from Employee A, Attendance B

          where A.empno = B.Empno;

  1. Inner Join (+) on the inside of the where condition before = sign

         Select * from Employee A, Attendance B

         Inner join on Employee A

         Where A. Empno(+) = B. Empno

  1. Outer Join (+) on the outer part of the where condition after = sign

          Select *n  from Employee A, Attendance B

          Outer Join on Attendance B

          Where A. empno = B.empno(+);