Normalization
Normalization
A real estate management company keeps track of the properties it manages, owners of the
properties, and clients (tenants in the properties). Each owner of a property has a name and a
unique number. An owner can own a number of properties, each of which has a unique number,
and address (physical location). The company keeps record of each clients name, client ID
(national ID number), rent amount, and tenancy period (rent_start and rent_finish). A client may
rent one or more properties. A property can be rented by only one client at any given time period.
2) Normalization
Unnormalized Form (UNF)
Client_ID, Client_Name, Property_ID, Property_Address, Rent_Start, Rent_Finish, Rent,
Owner_ID, Owner_Name.
First Normal Form (1NF) (Remove the repeating groups)
Client_ID, Client_Name,
Client_ID, Property_ID, Property_Address, Rent_Start, Rent_Finish, Rent, Owner_ID,
Owner_Name.
Second Normal Form (2NF) (Based on the concept of full functional dependency)
Client_ID, Client_Name,
Client_ID, Property_ID, Rent_Start, Rent_Finish,
Property_ID, Property_Address Rent, Owner_ID, Owner_Name.
Third Normal Form (3NF) (Remove transitive dependencies)
Clients (Client_ID, Client_Name)
Rentals (Client_ID, Property_ID, Rent_Start, Rent_Finish)
Properties (Property_ID, _Address, Rent, Owner_ID)
Owners (Owner_ID, Owner_Name)
1|Page
Clients
Client_ID
Client_Name
Rentals
Client_ID
Property_ID
Rent_start
Rent_finish
Properties
Property_ID
Property_Address
Rent
Owner_ID
Properties
Property_ID
Property_Address
Rent
Owner_ID
Client_ID
Property_ID
Rent_start
Rent_finish
Owners
Owner_ID
Owner_Name
4) Creating the database and tables and populating the tables with 10 records
Creating the database
CREATE DATABASE RealEstatedb
datafile /u01/oracle/oradata/RealEstate/sys.dbf size 500M
sysaux datafile /u01/oracle/oradata/RealEstate/sysaux.dbf size 100m
undo tablespace undotbs
datafile /u01/oracle/oradata/RealEstate/undo.dbf size 100m
default temporary tablespace temp
tempfile /u01/oracle/oradata/RealEstate/tmp.dbf size 100m
logfile
group 1 /u01/oracle/oradata/RealEstate/log1.ora size 50m,
group 2 /u01/oracle/oradata/RealEstate/log2.ora size 50m;
2|Page
3|Page
4|Page
5|Page
5) Creating database users and assigning them different rights to different tables
CREATE USER User1 IDENTIFIED BY pwrd1;
DEFAULT TABLESPACE users
TEMPORARY TABLESPACE temp;
GRANT CONNECT, UPDATE, INSERT ON clients TO User1;
CREATE USER User2 IDENTIFIED BY pwrd2;
DEFAULT TABLESPACE users
TEMPORARY TABLESPACE temp;
GRANT SELECT ON rentals TO User2;
CREATE USER User3 IDENTIFIED BY pwrd3;
DEFAULT TABLESPACE users
TEMPORARY TABLESPACE temp;
GRANT SELECT, INSERT, UPDATE, DELETE ON properties TO User3;
CREATE USER User4 IDENTIFIED BY pwrd4;
DEFAULT TABLESPACE users
TEMPORARY TABLESPACE temp;
GRANT CONNECT, RESOURCE ON owners TO User4;
6|Page
7) Database query linking at least three tables and using mathematical operators
SELECT * FROM clients, rentals, properties,
WHERE clients.client_ID = rentals.client_ID(+)
AND rentals.property_ID = properties.property_ID(+);
7|Page