You are on page 1of 18

POLITEKNIK BALIK PULAU

KEMENTERIAN PENDIDIKAN TINGGI

DFC2083
DATABASE DESIGN

LAB ACTIVITY 5

LECTURER NAME PUAN HAMIDAH BINTI OSMAN

CLASS DDT2B

GROUP NAME SITI NORFADHILAH BT MASKOR
(21DNS17F2026)
NURUL NAZIRA BT AMIN
(21DNS17F2013)
SYAZWINA ZURAIN BT ROHAIZAD
(21DNS17F2054)
ANIS AZRINA BT NAZRI
(21DNS17F2065)

LAB ACTIVITY 5: Structured Query Language (SQL)

Duration : 8 Hours Learning Outcomes This activity encompasses of activities from 5A to 5D. you should be able to: 1. . Understand and apply SQL Functions Hardware/ Software : MySQL Activity 5A Activity Outcome: Able to create Database. Understand and apply DDL commands 2. Understand and apply DML commands 3. Understand and apply SQL Advanced commands 4. Step 2 : Create tables VENDOR and PRODUCT. By the end of this laboratory session. tables and manipulates tables using DDL statements Procedures Step 1 : Create new database name COMPANY.

.Step 3 : Click on SQL tab and type the SQL command(VENDOR table) as shown below. Step 4 : Run the SQL command. Step 5 : Save the Query. Step 7 : Type SQL command to change the P_ITEM character length from 35 to 40. Step 6 : Click on SQL tab to create PRODUCT table.

Step 8 : Type SQL command to Add attribute V_AGE into table VENDOR. . Step 9 : Type SQL command to change the data type attribute V_AGE from INT to CHAR.

Step 10 : Type SQL command to Delete attribute V_AGE from table VENDOR. Step 11 : Type SQL command to delete VENDOR table. .

Activity 5B Activity Outcome: Able to manipulates tables using DDL statements (Refer Activity 5A) Procedures: Step 1 : Click on SQL tab and type SQL command that insert new data into PRODUCT table . . Step 2 : Type the following SQL command to insert another data into PRODUCT table.

Step 3 : Click on SQL tab. . Step 4 : Type SQL command to update a data in the PRODUCT table. Step 6 : Click on SQL tab and type SQL command to delete a data in the PRODUCT table using the following command. Step 5 : Click on SQL tab and type SQL command to delete a data in the PRODUCT table using the following command.

Activity 5C Appendix B Database : CAR CUSTOMER custid custname Car_number Phone_number Register_date P0001 David Lim WKM 1234 0139845263 12/06/14 P0002 Abu Hassan DBA 8999 0126377298 23/05/14 P0003 Low Ban Huat PFL 3434 0197894563 05/01/14 P0004 Karigalan BGN 2511 0112356897 23/05/13 P0007 Kamal Ibrahim WEP1103 0145689471 12/07/14 CAR_COMPONENT compID compName price KK001 ISWARA Rear Lamp 100 KK002 WIRA Front Bumper 450 KK003 ISWARA Front Mirror 500 KK004 WAJA Break Lamp 250 KK005 WIRA Front Lamp 350 CLAIM claimID claim_date custid CL001 02/06/14 P0002 CL002 10/07/14 P0001 CL003 24/07/13 P0004 CL004 05/08/14 P0002 CL012 07/07/14 P0003 COMPONENT_CLAIM claimID compID quantity CL001 KK002 1 CL001 KK005 2 CL003 KK001 2 CL012 KK003 1 CL004 KK001 2 CL002 KK003 1 CL003 KK003 1 .

Activity Outcome: Able to understand and apply SQL Advanced commands Procedures: Step 1 : Open any Database software. Step 2 : Create new blank database name CAR. (Refer Appendix B) .

Step 3 : Create table CUSTOMER. CLAIM and COMPONENT_CLAIM . CAR_COMPONENT. .

.Step 4 : Insert attributes of each table. Step 5 : Insert All the data into each table.

Step 6 : Open the SQL Editor. . Step 7 : Type SQL command to find customer name from CLAIM table.

Step 10 : Open the SQL Editor and type SQL command to display car number begin with D.Step 8 : Open the SQL Editor. Step 11 : Open the SQL Editor and type SQL command to display claim ID and quantity where claim number is CL001 and CL012. component name and price where price is between 200 and 400. . Step 9 : Type SQL command to display component ID.

(Refer Activity 5C) Procedures: Step 1 : Open the SQL Editor and type SQL command to find the minimum value for price in the COMPONENT table Step 2 : Open the SQL Editor and type SQL command to find the maximum value for price in the COMPONENT table .Activity 5D Activity Outcome: Able to understand and apply SQL Functions.

Step 3 : Open the SQL Editor and type SQL command to find the average value for price in the table COMPONENT. Step 5 : Open the SQL Editor and type SQL command to sum the price in the table COMPONENT . Step 4 : Type SQL command to find average value for quantity in the table COMPONENT_CLAIM.

.Step 6 : Type SQL command to sum the components quantity in the table COMPONENT_CLAIM. Step 7 : Open the SQL Editor and type SQL command to count the number of customers Step 8 : Type SQL command to count the rows in CLAIM table.

. Step 10 : Open the SQL Editor and type SQL command to find the total quantity group by claimID which less than 1 in COMPONENT_CLAIM table.Step 9 : Open the SQL Editor and type SQL command to sum the quantity component group by claim number.