You are on page 1of 9

ELECTRICAL ENGINEERING DEPARTMENT

JUNE 2014 SESSION

EC601 DATABASE SYSTEMS


PRACTICAL WORK 1
Assessment Sheet

Practical Skill
Assessment

A. Create database and table. (Activity 1A,1B and 1C)

/ 30

B. Change table structure. (Activity 1D,1E,1F and 1G)

/ 40

C. Manipulate the data. (1H,1I and 1J)

/ 30
TOTAL

NAME :
REGISTRATION # :
PROGRAM:
PRACTICAL WORK :
DATE :

/ 100

EC601 Database System

PRACTICAL WORK 1: Introduction


Structured Query Language (SQL) DDL
and DML
Duration: 2 Hours
Learning Outcomes:
This lab sheet encompasses activity 1A to 1J.
By the end of this laboratory session, student should be able to:
1. Create database and table.
2. Change table structure.
3. Manipulate the data structure.
Hardware/Software: MySQL Workbench 5.2 OR MySQL CLI

Activity 1A

Activity Outcome: Create database.


Create database named DTK6XX.
Procedures:
Step 1: click button START-> MySQL->MySQL 5.5 Command Line Client Interface.

EC601 Database System

Step 2: Type the following SQL command and click button Execute. OR type
command-line below and press Enter

CREATE DATABASE DTK6XX(put any appropriate name for your database);

And SHOW DATABASES; and press Enter.

[Hint : dont forget the semicolon sign ;.]


Activity 1B
Activity Outcome: Create table in the database.
Create tables named STUDENT, SUBJECT and RESULT.
Procedures:
Step 1: Click on SQL tab or {CLI - Run command USE your_database_name; and Enter}
Step 2: Type the following command and click Execute.
Table Student;
CREATE TABLE STUDENT
(
STUNO VARCHAR(3) PRIMARY KEY,
STUNAME VARCHAR(30),
ADDRESS VARCHAR(30)
);
Step 3: Type command DESC STUDENT; and press Enter. Please take a note / print
result.
Mark: 2

10

EC601 Database System


Step 4: Type the following command and click Execute.
Table Subject;
CREATE TABLE SUBJECT
(
SUBJECTCODE VARCHAR(5),
SUBJECTNAME VARCHAR(30),
PRIMARY KEY (SUBJECTCODE)
);
Step 5: Type command DESC SUBJECT; and press Enter. Please take a note / print
result.
Mark: 2

10

Step 6: Type the following command and click Execute.


Table Result;
CREATE TABLE RESULT
(
STUNO VARCHAR(3),
SUBJECTCODE VARCHAR(5),
MARK INT,
GRADE CHAR(1)
);
Step 7: Check the tables structure by run command line .
Step 8: Type command DESC RESULT; and press Enter. Please take a note / print
result.

Mark: 2

10

EC601 Database System

Activity 1C
Activity Outcome: Create duplicate table in the database.
Procedures:
Step 1: Click SQL tab OR continue CLI
Step 2: Type the following SQL command and click Execute.
CREATE TABLE STUDENT2
AS SELECT * FROM STUDENT;
Step 3: Type command SHOW TABLES; and press Enter.
Step 4: Type command SELECT * FROM STUDENT2; and press Enter. Please take a
note / print result.

Activity 1D
Activity Outcome: Add column in existing table.
Procedures:
Step 1: Click SQL tab OR continue CLI
Step 2: Type the following SQL command and click Execute.
ALTER TABLE STUDENT2
ADD EMAIL VARCHAR(20);
Step 3: Type command DESC STUDENT2; and press Enter. Please take a note / print
result.
Mark: 2
4
6
8
10

EC601 Database System

Activity 1E
Activity Outcome: Modify column in existing table.
Procedures:
Step 1: Click SQL tab OR continue CLI
Step 2: Type the following command and click Execute.
ALTER TABLE STUDENT2
MODIFY EMAIL CHAR(25);

Step 3: Type command DESC STUDENT2; and press Enter. Please take a note / print
result.
Mark: 2

10

Activity 1F
Activity Outcome: Delete column in existing table.
Procedures:
Step 1: Click SQL tab OR continue CLI
Step 2: Type the following command and click Execute.
ALTER TABLE STUDENT2
DROP EMAIL;
Step 3: Type command DESC STUDENT2; and press Enter. Please take a note / print
result.
Mark: 2
4
6
8
10

EC601 Database System

Activity 1G
Activity Outcome: Delete existing table.
Procedures:
Step 1: Click SQL tab OR continue CLI
Step 2: Type the following command and click Execute.
DROP TABLE STUDENT2;
Step 3: Type command SHOW TABLES; and press Enter. Please take a note / print
result.
Mark: 2
4
6
8
10

Activity 1H
Activity Outcome: Insert record in existing table(s).
Procedures:
Step 1: Click SQL tab OR continue CLI
Step 2: Type the following command and click Execute.
INSERT INTO STUDENT
VALUES ('S01','HILDA','KUCHING');
INSERT INTO STUDENT
VALUES ('S02','DARYL','MIRI');
INSERT INTO STUDENT
VALUES ('S03','GANESH','SERIAN');
INSERT INTO STUDENT
VALUES ('S04','SUZANA','KUCHING');
INSERT INTO STUDENT
VALUES ('S05','KYLE','SIBU');
INSERT INTO STUDENT
VALUES ('S06','NEELAM','KAPIT');

Step 3: Type command SELECT * FROM STUDENT; and Enter. Please take a note /
print result.

EC601 Database System

Step 4: Type the following command and click Execute.


INSERT INTO SUBJECT
VALUES('EC601','DATABASES SYSTEMS');
INSERT INTO SUBJECT
VALUES('ET101','ELECTRICAL TECHNOLOGY');
INSERT INTO SUBJECT
VALUES('ET102','ELECTRICAL WIRING');

Step 5: Type command SELECT * FROM SUBJECT; and Enter. Please take a note /
print result
Step 6: Type the following command and click Execute.

INSERT INTO RESULT


VALUES('S01','EC601', 80, 'A');
INSERT INTO RESULT
VALUES('S02','EC601', 75, 'B');
INSERT INTO RESULT
VALUES('S03','EC601', 55, 'C');
INSERT INTO RESULT
VALUES('S05','ET101', 82, 'A');
INSERT INTO RESULT
VALUES('S04','ET101', 85, 'A');
INSERT INTO RESULT
VALUES('S06','ET102', 78, 'B');

Step 7: Type command SELECT * FROM RESULT; and Enter. Please take a note /
print result

Mark: 2

10

EC601 Database System

Activity 1I
Activity Outcome: Modify record in existing table(s).
Procedures:
Step 1: Click SQL tab OR continue CLI
Step 2: Type the following command and click Execute.
UPDATE STUDENT
SET STUNAME = HILDA SWANN
WHERE STUNO = S01;

Step 3: Type command SELECT * FROM STUDENT; and Enter. Please take a note /
print result
Mark: 2

10

Activity 1J
Activity Outcome: Delete record in existing table(s).
Procedures:
Step 1: Click SQL tab OR continue CLI
Step 2: Type the following command and click Execute.
DELETE FROM STUDENT
WHERE STUNO = 'S06';
Step 3: Type command SELECT * FROM STUDENT; and Enter. Please take a note /
print result
Mark: 2

10