You are on page 1of 2

CIS 331 Summer 2014

Homework 01
Student:

If you use graphical user interface to answer the questions, you should copy the SQL
statements into one file, either plain text or MS-Word file. Data in SQL is case sensitive.
Adjust cases on your own. Name your file CIS331HW1_LastFirst. Also include your name
inside your homework file.
All SQL programs should be in text mode that I can copy/paste to test.

This is a sample database.
Course
COURSE_ID DESCRIPTION CREDIT PREREQUISITE LEVEL CREATED_DATE
20 Intro to Information Systems 2 - UG August 1, 2010
25 Intro to Programming 2

UG August 1, 2010
100 Hands-On Windows 3 20 UG January 1, 2011
122 Intermediate Java 3 25 UG January 1, 2011
204 Intro to SQL 3 20 U May 1, 2011
210 Oracle Tools 3 204 UG May 1, 2011
310 Operating Systems 3 - G May 1, 2011
350 Java Developer II 3 122 G May 1, 2011
420 Database System Principles 3 210 G May 1, 2011
450 DB Programming with Java 5 350 G May 1, 2011

1. (40 points) Write a SQL program to create the Course table as above.
Course_ID is primary key.
You determine data type and length for each column. They must be reasonable.
Description shouldnt be empty.
Description should be unique.
Level only accepts UG and G.
Credit should be between 0 and 4.
Besides the SQL program, you should also show a screen capture with your username and
this table being created.

2. (25 points) Write SQL programs to insert above sample records into Course table. If you
violate constraint and cannot enter data, include error message in your answer.

Use SELECT * FROM course to show your results.

3. (20 points) Write SQL programs to insert and modify records as described below.
a. Insert a record using the last three digits of your KSI ID as Course_ID, using your own
name as Description, making up data for the rest columns yourself.
b. Modify (Description) Database System Principles to Database System Management.
c. Change Operating Systems to Course ID 304 and Level UG.

Use SELECT * FROM course to show your results.

4. (15 points) Write SQL programs to Delete courses whose course IDs are smaller than 99.
Use SELECT * FROM course to show your results.

You might also like