Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 8

Domains

• Any attribute of an entity type or field of a


table will have valid and invalid values.
• The domain for an attribute specifies what
is valid and invalid.
• i.e. data type, length/ size, NULL, specific
values, conditions, key
datatype
• Varchar2(length) variable length, does
not allocate space unless required
• Number(size)
– number(2) integer number
– number(4,1) has one decimal place
• Date can hold date or time
• Interval number
• Timestamp date / time with world zones
Null
• A field can be defined as NOT NULL

• E.g.
• my_name varchar2(5) not null;

• If it is not defined it will allow NULLS.


initialisation
• Fields can be initialised value

• E.g. sname varchar2(3) default ‘joe’;

• This can be overwritten by new


information .
• If no entry is made the field will contain
‘joe’.
check
• A field can have a check condition put on it
which only allows entries that are correct
to be entered.
• A check condition can also be added as a
table constraint (like primary key and
foreign key) to combine tests on different
fields.
• NOTE. A check condition can only work
with fields in one table.
Gender varchar2(1) default ‘F’ constraint
staff_gender_ck CHECK(gender IN(‘F’,’M’)),

DOB date,
startDate date,
Constraint date_ch CHECK(DOB < startDate)
• Constraint tablename_pk PRIMARY
KEY(fieldname)

• Constraint tablename_field_fk FOREIGN


KEY(fieldname) REFERENCES
tablename(fieldname)

You might also like