Making a design sketch

The table called friends_etc is used in this chapter and subsequent chapters to illustrate how to create indexes, defaults, rules, triggers, and so forth. It can hold names, addresses, telephone numbers, and personal information about your friends. It does not define any column defaults or integrity constraints.

If another user has already created the friends_etc table, check with a system administrator or the database owner if you plan to follow the examples and create the objects that go with friends_etc. The owner of friends_etc must drop its indexes, defaults, rules, and triggers so that there is no conflict when you create these objects.

Table 8-4 shows the proposed structure of the friends_etc table and the indexes, defaults, and rules that go with each column.

Table 8-4: Sample table design

Column

Datatype

Null?

Index

Default

Rule

pname

nm

NOT NULL

nmind(composite)

sname

nm

NOT NULL

nmind(composite)

address

varchar(30)

NULL

city

varchar(30)

NOT NULL

citydflt

state

char(2)

NOT NULL

statedflt

zip

char(5)

NULL

zipind

zipdflt

ziprule

phone

p#

NULL

phonerule

age

tinyint

NULL

agerule

bday

datetime

NOT NULL

bdflt

gender

bit

NOT NULL

gndrdflt

debt

money

NOT NULL

gndrdflt

notes

varchar(255)

NULL