constraints : conditions defined on
table columns.
ex:
course_dur should be either 180 or 240
ex:
student age should be minimum 18
Types
of constraints:
1. Null : column can accept null values
Not null : column
cannot accept null values
2. unique : column does not accept duplicates but can accept upto 1 null values
3. primary key : column does not accept duplicates and cannot accept null
values
4. foreign key : column accept values based on a different column in same/different table for table to table communication (references)
ex:
assume a courses table with few courses. students
table should reference above courses table staff
table should reference above courses table
5. check
constraint : used to specify conditions on column values
ex: student
gender should be either 'm' or 'f'
6. default
constraint : used to specify a default value.
applicable
for inserts when we do not speficy column name & value
7. indentity
property : used to generate a sequence of integer values *
No comments:
Post a Comment