LECTURE: Database Overview
PAGES: Chapter 1 & 2, pp 6 – 64
(largely overview pages that can be read quickly – most of this material
will be revisited later in greater depth)
HIGHLIGHTS:
Database System compared to traditional file systems
LAB : Start LAB 1
LECTURE: SQL (“select” statement)
PAGES: section 6.3.3 pp246-7; sections 6.4.1 –
6.4.4 pp251 – 264; sections 6.6.1 – 6.6.4 pp 272 – 284
HIGHLIGHTS: between; like; in; exist; order by; distinct; aggregate
functions; group by/having
LAB: : Labs 1 due; Start lab 2
LECTURE: SQL (“select” statement)
PAGES: sections 6.8 – 6.8.3 pp 286 – 291;
sections 7.1 – 7.4.4 pp 320 – 348
HIGHLIGHTS: joining; set operators; subqueries; any/all; correlated subqueries;
date/time functions.
SQL
SERVER: Housekeeping; Stored Procedure
LECTURE: POSTPONED
PAGES:
HIGHLIGHTS:
LAB
LECTURE: Action Queries; Creating VIEWS,
Stored Procedures; Review parts of week 3
PAGES: section 6.3.1, pp 243 –
245; section 6.3.4, pp 247 – 248; sections 6.3.6 – 6.3.7, p 249; section 6.7,
pp 284 - 285
HIGHLIGHTS: insert; update; delete; VIEWS
LAB:
LAB 3 due; start lab 4
LECTURE:
SQL Review; CURSORS
PAGES:
HIGHLIGHTS: .
LAB:
lab 4 due; start lab 5
LECTURE: QUIZ 1 (SQL)
PAGES: pp 95 - 107
HIGHLIGHTS: . intro to E-R modeling; cardinalities;
indexes
LAB:
lab 5due; start lab 6
WEEK 8 (
LECTURE: DESIGN: ER modeling
PAGES: chapter 4 pp 124 - 169
HIGHLIGHTS: .
LAB:
lab 6 due; start lab 7
WEEK 9 (
LECTURE:
PAGES
HIGHLIGHTS: .
LAB:
lab 7 due; start lab 8
WEEK 12 (11/15/05)
LECTURE: quiz 3 due
PAGES: : main text, ch 5,
pp 184 - 201
HIGHLIGHTS: .
LAB:
LECTURE: QUIZ 4 : Data Modeling (ER
diagrams); Normalization
PAGES:
HIGHLIGHTS:
LAB:
LECTURE
PAGES:
HIGHLIGHTS:
LAB:
LECTURE LAST DAY
PAGES:
HIGHLIGHTS:
LAB: project due
WORKER |
||||
WORKER_ID |
WORKER_NAME |
HRLY_RATE |
SKILL_TYPE |
SUPV_ID |
1235 |
M. FARADAY |
12.5 |
ELECTRIC |
1311 |
1311 |
C. COULOMB |
15.5 |
ELECTRIC |
1311 |
1412 |
C. NEMO |
13.75 |
PLUMBING |
1520 |
1520 |
H. RICKOVER |
11.75 |
PLUMBING |
1520 |
2920 |
R. GARRETT |
10 |
ROOFING |
2920 |
3001 |
J. BARRISTER |
8.2 |
FRAMING |
3231 |
3231 |
P. MASON |
17.4 |
FRAMING |
3231 |
ASSIGNMENT |
|||
WORKER_ID |
BLDG_ID |
START_DATE |
NUM_DAYS |
1412 |
111 |
12/1/1997 |
4 |
3001 |
111 |
10/8/1997 |
14 |
3231 |
111 |
10/10/1997 |
8 |
1412 |
210 |
11/15/1997 |
12 |
2920 |
210 |
11/10/1997 |
15 |
3001 |
210 |
10/27/1997 |
14 |
1235 |
312 |
10/10/1998 |
5 |
1412 |
312 |
10/1/1997 |
10 |
1520 |
312 |
10/30/1997 |
17 |
3231 |
312 |
10/24/1997 |
20 |
1311 |
435 |
10/8/1997 |
12 |
1412 |
435 |
10/15/1997 |
15 |
2920 |
435 |
10/28/1997 |
10 |
1311 |
460 |
10/23/1997 |
24 |
1412 |
460 |
12/8/1997 |
18 |
2920 |
460 |
10/5/1997 |
18 |
1235 |
515 |
10/17/1998 |
22 |
1412 |
515 |
11/5/1997 |
8 |
1520 |
515 |
10/9/1997 |
14 |
BUILDING |
||||
BLDG_ID |
BLDG_ADDRESS |
TYPE |
QLTY_LEVEL |
STATUS |
111 |
1213 ASPEN |
OFFICE |
4 |
1 |
210 |
1011 BIRCH |
OFFICE |
3 |
1 |
312 |
123 ELM |
OFFICE |
2 |
2 |
435 |
456 MAPLE |
RETAIL |
1 |
1 |
460 |
1415 BEECH |
WAREHOUSE |
3 |
3 |
515 |
789 OAK |
RESIDENCE |
3 |
1 |
SELECT A.CLASS
FROM CLASSES A
WHERE NOT EXISTS
(SELECT *
FROM STUDENT B
WHERE NOT EXISTS
(SELECT *
FROM ENROLL C
WHERE A.CLASS = C.CLASS AND
B.SID = C.SID));
HANDOUT #8:
A M 23
B M 19
C M 32
D H 35
E H 42
F H 25
G A 18
H A 22
I A 27
(output)
C M 32 avg= 24
D H 35 avg= 34
E H 42 avg= 34
I A 27 avg= 22
HANDOUT #11: CLASS PROJECT
NOTE:
You will stock many tapes of the same movie.
Submit the following documentation in the order below:
***************************************
1. Create STUDENT DATABASE (see handout #1) using MS ACCESS.
2. Using the QBE method, answer the following queries:
Query 1: List the names and ages of math majors .
Query 2: Display the average age of math majors.
Query 3: List the names of students enrolled in class
BD445.
Query 4: List the names of the students and their
class times - order by student name.
DIRECTIONS:
Display the completed lab to the instructor.
Use the student database.
Write SQL statements to answer the following QUERIES:
1. List the names of students who are between the ages of 18 and 24 (not including
18 & 24). List them in
ascending order by age.
Use the between operator.
2. List the names of the students who have the letter e in their name.
3. List the name and age of students who are either math or acctg majors.
Do it 2 different ways:
A. Use the “or” operator.
B. Use the in operator.
4. List the different majors – no duplicates.
5. What is the maximum age of accounting majors?
6. List the major and the number of students in each major.
7. List the majors with more than 2 students.
DIRECTIONS: (the same for subsequent labs)
1.Use a cover sheet.
2. Print the SQL statements and the output for each query.
LAB #4
Use PREMIER Database.
Write SQL statements to answer the following queries:
1.
A.)
Use the following “select statement” to create a “worker2” table
SELECT * INTO WORKER2 FROM WORKER
A.) Use the following “select statement” to create a “assignment2” table
SELECT * INTO ASSIGNMENT2 FROM
ASSIGNMENT
*************************************************************
USE WORKER2 AND ASSIGNMENT2 TABLES
FOR THE ACTION QUERIES BELOW
2. Increase all the hourly rates by 10% - use the update command. Show the
resulting table.
3. Add the following assignment using the insert
command: (Show the resulting table.)
worker_id:
3231
bldg_id:
515
start_date:
12/1/1997
num_days: 9
4. Delete all the “electric” workers –
use the delete command. Show the resulting table.
5. Use the insert command to add the “electric” workers from table worker to table worker2. Show the resulting
table.
FINISH USING WORKER2 & ASSIGNMENT2 TABLES
******************************************************************
6. List the workers whose hourly rate exceeds their supervisor’s hourly
rate. Include the following info in your
output:
worker id, worker hrly rate, supervisor hrly rate.
7. List the worker_id
and skill_type of those workers whose hrly rate exceeds the average hrly
rate of their skill_type.
8. List the skill_type that has the highest
average hrly rate.
.
1. List the product id and total dollar amount per product.
2. List the
product id, description and total qty sold per product.
3. List the
product id and the total units sold for those products with at least 25 units
sold.
4. List the
id of the salesperson having the largest single transaction of qty
sold.
5. List the
product id and the salesperson id for the salesperson having the single
highest transaction (qty sold) for each product. Order by product
id.
LAB #8
Use NATIONAL BANK database (available in shared folder).
Write SQL statements to answer the following queries:
Use NATIONAL BANK database
(available in shared folder).
Write SQL statements to answer the following queries: