Constraints are conditions prototype rules and applying on tables or columns in other database constraints are
(a)Domain-Based – Not null x
Check These are attribute of Teradata
Default
b) Entity-based – primary key[pk]
- unique key[UK]
c) Reference based-foreign key [FK]
Unique unique values (allows one null)
Primary unique values + Not null+ No duplicate values
Check validates against a condition
References Works like foreign key
Constraints (Condition or restriction on the column's data)
Inclined to build a profession as Teradata Developer? Then here is the blog post on, explore Teradata Training
a) Column Level On a single column we take constraint
b)Table level On multiple columns(Composite key) we take constraints.
Syntax: Column Name data type constraint <Constraint name>
Primary key/unique/check/references.
Example:
Create set table dept
(
D Code integer primary key Not null,
D name varchar(30)
D income integer constraint CHK
Check(DINcome>30000)
)
Create set table emp
(
EID integer unique not null,
Ename varchar(30)
D Code integer constraint ref
References Dept(D code)
)
Create set table dept1
(
Party ID integer
Pname varchar(30) not null,
P DOB not null, primary key(Pname, PDOB)
)
Note: In the above situation p name, PDOB is used for unique identification of the record
PID |
Pname |
1 |
X |
2 |
X |
1 |
Y |
2 |
X |
3 |
X |
We can remove the data in the parent even the value existed in the child
Implemented with no check option
Referential integrity
Example
Create set table emp
(
EID Integer unique, not null,
Ename varchar(30),
DCode integer constraint ref
References with no check option dept(Dcode)
)
Note
P, K UK required not null at the column level because they are associated with the index concept.
You liked the article?
Like: 0
Vote for difficulty
Current difficulty (Avg): Medium
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.