Professional Documents
Culture Documents
Databases
Tutorial 3: Data Modelling
Part 2: SQL
A table is in 1NF: if and only if all underlying simple domains contain atomic values only.
A table is in 2NF: It should satisfy the rule that a non-key attribute must be a fact about
the whole key, not part of the key.
A table is in 3NF: It should avoid that a non-key attribute provides a fact about another
non-key attribute (i.e., non-transitive dependency).
1 3&4
Registration Registration
clientNo branchNo staffNo dateJoined
• The combination of clientNo and branchNo is the primary key for
CR76 B005 SL41 2004-04-02 Registration table
CR56 B003 SG37 2004-04-11 • There are three (3) foreign keys:
• Client (clientNo)
CR74 B003 SG37 2004-11-16 • Staff (staffNo)
CR62 B007 SA9 2004-03-07 • Branch(branchNo)
* Branch and Staff tables already exist in the Dream Homes database
Client
clientNo fname lname telNo preType maxRent
Client
CR56 Aline Stewart 0414-848-1825 Flat 350
• clientNo is the primary key
CR62 Mary Tregear 0224-196720 Flat 600
• maxRent in the table is decimal type
CR74 Mike Ritchie 01475-392178 House 750
CR76 John Kay 0207-774-5632 Flat 425
Q2. Identify columns and their data types (attributes and domains).
From the schema, we can identify primary key and foreign key.
Registration
Client
• Restrict option:
To prevent the parent table from being deleted if any other tables
refer to it (foreign key).
• Cascade option:
To always delete the parent table together with all the tables
where they are referred (foreign key).