Professional Documents
Culture Documents
(Fall 2011)
TA:
Eyup Ayaz, Viru Kanjilal, Hechen Liu
Homework 1Solutions
Name:
UFID:
Email Address:
_______________________________________________
Signature
Maximum
Exercise 1
30
Exercise 2
30
Exercise 3
40
Total
100
Received
external/view level describe the part of the DB, which is relevant for the user
John
James
Alex
Jean
Kate
Mike
Peter
FL
FL
CA
CA
FL
NC
NC
03/15/1984
10/20/1984
05/17/1985
08/23/1985
11/14/1985
01/25/1986
11/20/1986
Purchase_
Amount
100.00
68.00
32.00
54.50
89.99
110.00
76.25
Use your CISE Oracle account to create this table and perform the operations below
Provide SQL statements for all operations. Show outputs of all your resulting Oracle. [6
points each]
(a) Create the CUSTOMERS table
CREATE TABLE CUSTOMERS(
CustomerID integer,
Name varchar(50),
State varchar(2),
Birthday date,
Purchase_ Amount numeric(5,2),
primary key(CustomerID));
(b) Insert data into the table
INSERT INTO STUDENTS VALUES(1001,John, 'FL' ,15-MAR-1984,100.00);
INSERT INTO STUDENTS VALUES(1002,James','FL',20-OCT-1984,68.00);
INSERT INTO STUDENTS VALUES(1003,Alex','CA',17-MAY-1985,32.00);
INSERT INTO STUDENTS VALUES(1004,Jean','CA',23-AUG-1985,54.50);
INSERT INTO STUDENTS VALUES(1005,Kate','FL',14-NOV-1985,89.99);
INSERT INTO STUDENTS VALUES(1006,Mike','NC',25-JAN-1986,110.00);
INSERT INTO STUDENTS VALUES(1007,Peter','NC',20-NOV-1986,76.25);
(c) Determine the customers who are from FL and born before 1/20/1985
SELECT Name from CUSTOMERS where State='FL' AND Birthday
< 20-JAN-1985;
John
Alex
(d) Find the names of the customers whose name starts with A
SELECT Name from CUSTOMERS where Name LIKE A%
(e) How many customers are in the CUSTOMERS table
SELECT count(*) as total from Customers;
When students work on a project, a professor must supervise their work on the
project.
Students can work on multiple projects, in which case they will have a
(potentially dierent) supervisor for each one.
Departments have a department number, a department name, and a main
oce.
Departments have a professor (known as the chairman) who runs the
department.
Professors work in one or more departments, and for each department that
they work in, a time percentage is associated with their job.
Students have one major department in which they are working on their
degree.
Each student has another, more senior student (known as a student advisor)
who advises him or her on what courses to take.
Design and draw an ER diagram that models the information about the university.
[Points: 30]