Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

JABATAN TEKNOLOGI MAKLUMAT DAN KOMUNIKASI

POLITEKNIK UNGKU OMAR


SESI 1 2021/2022
KOD KURSUS : DFC 20123
NAMA KURSUS : DATABASE DESIGN
PENILAIAN : LABORATORY TASK 3

SESI SEMASA : 1 2021/2022


SEKSYEN KURSUS : DDTN3 / DDTP3 / DDTS3
NAMA PENSYARAH KURSUS :

ARAHAN PENILAIAN:
1. Jawab semua / pilihan soalan dalam masa ……1.5…….minit/jam/hari
2. Jawapan adalah secara individu/berkumpulan (2 orang /kumpulan).
3. Kembalikan soalan setelah selesai menjawab / Soalan boleh disimpan oleh pelajar.

NO.
NAMA CLO MARKAH
PENDAFTARAN
01DDT20F2006 THAYALAN A/L RAMASAMY 1 -
2 / 20
3 -
Jumlah / 20

Disediakan oleh: Disemak dan Disahkan oleh:

NOR ANISAH BINTI MOHD SAAD


Peg. Pend. Pengajian Tinggi
Jab. Tekno. Makl. & Komunikasi
Politeknik Ungku Omar
31400 Ipoh Perak
LABORATORY TASK 3 DFC 20123 DATABASE DESIGN

CLO2: Show a well-structured database using the database query to manipulate a


database with an appropriate commercial Database Management System (DBMS) in
solving an organization’s requirements. (P2, PLO3)

You are working with Delima IT Solution to complete a database project for House Rental. Help
your team members to prepare a manual consist of step-by-step instruction and SQL commands for
the House Rental system. Write the appropriate MySQL command and screenshot the output to
show the steps taken based on the following steps / procedures:

Steps / Procedures:
a) Create a database name as DelimaHouseDB.
b) Create all the tables with description details shown in Figure 1.0. Display all the table’s
descriptions.

CUSTOMER

OWNER

HOUSE

RENT

Figure 1.0
LABORATORY TASK 3 DFC 20123 DATABASE DESIGN

c) Write the SQL statement to insert data into the tables as shown in Figure 2.0.

CUSTOMER

OWNER

HOUSE

RENT

Figure 2.0
LABORATORY TASK 3 DFC 20123 DATABASE DESIGN

d) Display all records that have been inserted into all tables.
e) Write SQL query display the result for the following situation:

i. Display all data for customer with ID = 3


ii. Update address for owner Rosmah to Taman Saujana
iii. Display all customer name with their house type and rent rate
iv. Display owner ID, owner name and house type for owner with ID = 2

INSTRUCTION:

 Based on the given scenario, follow the steps to complete the task and screenshot all the SQL
statement and result’s table which consist of:
a) SQL statement for DDL process (create database and tables)
b) Description for each table’s information
c) SQL statement to inserting data for each table
d) All data for each table

 Marks will be given based on the rubric.

 Submit your works through CIDOS platform.


mysql> create database DelimaHouseDB;
Query OK, 1 row affected (0.04 sec)

mysql> use DelimaHouseDB;


Database changed
mysql> create table CUSTOMER (
-> cID integer,cName varchar(50),cPhone varchar(15),primary key(cID));
Query OK, 0 rows affected (0.08 sec)
mysql> desc CUSTOMER;

mysql> create table OWNER(


-> oID integer,oName varchar(50),oPhone varchar(15),
-> oAddress varchar(100),primary key(oID));
Query OK, 0 rows affected (0.07 sec)

mysql> desc OWNER;

mysql> create table HOUSE(


-> hID integer,hType varchar(100),hAddress varchar(100),
-> oID integer,primary key(hID),foreign key(oID) references OWNER(oID));
Query OK, 0 rows affected (0.06 sec)
mysql> desc HOUSE;

mysql> create table RENT(


-> rID integer,rDate datetime,cID integer,
-> hID integer,rRate numeric(5,2),
-> primary key(rID),foreign key(cID) references CUSTOMER(cID),
-> foreign key(hID) references HOUSE(hID));
Query OK, 0 rows affected (0.11 sec)

mysql> desc RENT;

mysql> insert into CUSTOMER


-> (cID,cName,cPhone)
-> values
-> (1,'Husna','0196674133'),
-> (2,'Adilah','01938388392'),
-> (3,'Samsul','01567090087'),
-> (4,'Boon Chee Leong','0172658886'),
-> (5,'Ravi','0172226586');
Query OK, 5 rows affected (0.04 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> insert into OWNER
-> (oID,oName,oPhone,oAddress)
-> values
-> (1,'Salman','01966758761','Taman Bersatu, Ipoh');
Query OK, 1 row affected (0.02 sec)

mysql> insert into OWNER


-> (oID,oName,oPhone,oAddress)
-> values
-> (2,'Halim','01966752311','Taman Cempaka, Ipoh'),
-> (3,'Saiful','01961342222','Taman Cempaka, Ipoh'),
-> (4,'Kamal','01168762222','Taman Perpaduan, Ipoh'),
-> (5,'Rosmah','0156762988','Taman Bahagia, Ipoh');
Query OK, 4 rows affected (0.03 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> insert into HOUSE
-> (hID,hType,hAddress,oID)
-> values
-> (1,'teres 1 tingkat','Taman Mewah, Ipoh',2),
-> (2,'teres 2 tingkat','Taman Bersatu, Ipoh',1),
-> (3,'teres 2 tingkat','Taman Mulia, Ipoh',3),
-> (4,'apartment tingkat 2','Taman Indera, Ipoh',2),
-> (5,'teres 1 tingkat','Taman Perpaduan, Ipoh',2),
-> (6,'apartment tingkat 1','Taman Saujana, Ipoh',1);
Query OK, 6 rows affected (0.03 sec)
Records: 6 Duplicates: 0 Warnings: 0
mysql> insert into RENT
-> (rID,rDate,cID,hID,rRate)
-> values
-> (111,'2021-01-23 12:45:56',1,1,500.00),
-> (112,'2021-03-21 14:45:30',2,3,450.00),
-> (113,'2021-03-17 17:30:30',3,2,650.00);
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select * from CUSTOMER;

mysql> select * from OWNER;

mysql> select * from HOUSE;


mysql> select * from RENT;
mysql> select * from CUSTOMER
-> where cID = 3;

mysql> update OWNER


-> set oAddress = 'Taman Saujana, Ipoh'
-> where oName = 'Rosmah';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select cName,hType,rRate
-> from RENT
-> natural join CUSTOMER
-> natural join HOUSE;
mysql> select o.oID,o.oName,h.hType
-> from OWNER o
-> natural join HOUSE h
-> where oID = 2;
PLO3: Display Information and Communication Technology (ICT) skill in performing diagnostic and documenting processes in ICT related fields
CLUSTER 3a: Practical Skills

Excellent Good Proficient Basic STANDARD


Criteria & SCORE
4 3 2 1 WEIGHTAGE

SQL statement for create and using Shows the correct SQL
Shows the correct SQL Shows the correct SQL Shows the incorrect SQL
statement for creating and
database statement for creating and statement for creating statement for creating and [ ]/4*5
using database with
using database. database only. using database.
screenshot.
Create all tables Create all tables Create all tables Create tables
completely and shows the completely and shows the completely and shows the incompletely and shows
SQL statement for create table and
correct description correct description correct description the incorrect description
view description for each table’s [ ] / 4 * 20
(variable and data type) (variable and data type) (variable and data type) (variable and data type)
information
for all tables with perfect for all tables with suitable for at least 2 tables. for tables.
domain constraint. domain constraint.
Shows the correct and Shows the correct or Shows the correct or Shows the incorrect or
SQL statement inserting data for complete SQL statement complete SQL statement complete SQL statement incomplete SQL
for inserting data for all for inserting data for all for inserting data for at statement for inserting [ ] / 4 * 20
each table
tables. tables. least 2 tables. data for tables.

Display all data for all


Display all data for all Display all data for at Do not display data for
Display all data for each table tables with complete [ ] / 4 * 10
tables. least 2 tables tables.
screenshot.

Shows the correct and Shows the correct or Shows the correct or Shows the incorrect or
SQL Statements for situation complete SQL statement complete SQL statement complete SQL statement incomplete SQL [ ] / 4 * 25
for all situations for all situations for at least 2 situations statement for situations

Shows the complete and Shows the complete or Shows the complete or
Shows the incomplete
Screenshot output for the situation correct screenshot for all correct screenshot for all correct screenshot for at [ ] / 4 * 20
screenshot for situations
the situations the situations least 2 situations

[ ] / 100 [ ] / 100 * 20

TOTAL MARKS [ ] / 20

You might also like