FIT9132 Tutorial 6 Sample Solution
FIT9132 Tutorial 6 Sample Solution
FIT9132 2020 S1
License: Copyright © Monash University, unless otherwise stated. All Rights Reserved.
COPYRIGHT WARNING
Warning
This material is protected by copyright. For use within Monash University only. NOT FOR
RESALE.
1
6.2 Using SQL Developer Data Modeler
6.2.3 Develop a model - Stage 1 The Logical Mode
2
6.3 Property-Rental Model
6.3.1 Drawing Logical Model
Note:
● Surrogate keys of rent_agreement_no and dam_no added to RENT and DAMAGE
respectively. Note that when a surrogate key is added, a unique identifier is created
to maintain the natural key.
● Since the model is to be implemented in Oracle date and time can be stored in a
single DATE type attribute
● In one to one relationship between PAYMENT and DAMAGE, the FK should be
placed in DAMAGE (remember that you have to place FK in a relation such that the
database has less null values). Thus, the Dominant Role is set as PROPERTY and
the FK is placed in DAMAGE.
3
Part of the case study indicates that the payment type must be recorded as Rent, Bond or
Damage. This should be enforced by adding a CONSTRAINT. This constraint becomes part
of the database structure, if the user wishes to add a new option, say 'F' for future rent
payments then the structure must be altered.
The picture below shows controlling pay_type via a CONSTRAINT (CHK_PAY_TYPE) - add
a check clause to payment.pay_type:
The case study also indicates that it needs flexibility in the design to be able to add new, and
remove current, payment methods as circumstances change. This should be handled by
adding a LOOKUP table. Lookup tables are a good approach where there is likely to be a
need to extend the possible values for an attribute. In the diagram, we add a new relation
(PAYMETHOD) and add a relationship between PAYMETHOD and PAYMENT relation. Note
that the name of FK can be different from PK name. You can change the name of FK by
double click the FK attribute in child relation → change the attribute name.
4
5
6.3.2 Generate Relational (Physical) Model
To capture the full run of your schema file you must insert a SPOOL and ECHO on
command at the top of your file, and a SPOOL OFF and ECHO off at the end of your script.
Please check the sample solution schema files to see this in action.