Constraints

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]

Teradata Constraints

Unique  2 unique values (allows one null)

Primary   2 unique values + Not null+ No duplicate values

Check   2 validates against a condition

References  2 Works like foreign key

Constraints  2 (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

Constraints applied at two levels

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)

)

2Create set table emp

(

EID integer unique not null,

Ename varchar(30)

D Code integer constraint ref

References Dept(D code)

)

Table-level constraints

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

Table level constraints

Teradata Interview Questions

Multiple column levels(composite)

PID

Pname

1

X

2

X

1

Y

2

X

3

X

Soft referential integrity

2We can remove the data in the parent even the value existed in the child

2Implemented with no check option

2Referential integrity

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.

For In-depth knowledge on Teradata click on: