First page Back Continue Last page Image

Building a Database – Data Consistency

We need to add something to our tables so we make sure we are talking apples to apples when making a connection or comparison

salestransaction

stxid

int(5)

PK

Not Null

productid

int(5)

FK

Not Null

customerid

int(5)

FK

Not Null

employeeid

int(5)

FK

Null

saledate

date

Not Null

saleamount

dec()

Not Null

product

prdid

int(5)

PK

Not Null

prdname

vc()

.

Not Null

prddesc

vc()

.

Null

prdinventory

int(5)

.

Null

prcost

dec()

Null

The PK and The FK Do not need to have the same name (But they can)

The PK and The FK should be the same data type and size (*1)

(*1) But there is noting stopping me from casting to a match

Here I have added the data type and in some cases size for each field