Ad Code

What is constraint? also attribute?


What is constraint? And what is difference between constraint and attribute?

Constraints are actually used to limit the type of data that can be inserted into a table. There are two basic types of constraints:


  1. Column Level 
  2. Table Level 

The difference between these two is that column level constraints are apply only to one column where as table level constraints are apply to whole table. Constraints are defined at the time of table creation using CREATE TABLE command.

For example, look into this simple query create table employee ( employee_id number not null); Here in this query Not null is a constraint, means employee_id column can not be null.

For attributes, you can consider them the properties of any entity. For example, employee is an entity. Then Employee_id, Name, Address, Salary would be its attributes. These attributes are maped into columns of the table when you make relations from ER diagram.
Reactions

Post a Comment

0 Comments