feat: 2102 and 2040s
This commit is contained in:
parent
78c03662c5
commit
7bf132f456
181
cheatsheets/cs2040s/finals.md
Normal file
181
cheatsheets/cs2040s/finals.md
Normal file
@ -0,0 +1,181 @@
|
||||
## Sorting
|
||||
| Algorithm | Best Time Complexity | Average Time Complexity | Worst Time Complexity | InPlace | Stable |
|
||||
| --------- | ------------------------ | -------------------------- | --------------------- | ------- | ------ |
|
||||
| Bubble | $O(n)$ comp, $O(1)$ swap | $O(n^2)$ comp, swap | $O(n^2)$ comp, swap | Yes | Yes |
|
||||
| Selection | $O(n^2)$, $O(1)$ swap | $O(n^2)$ comp, $O(n)$ swap | $O(n^2)$, O(n) swap | Yes |
|
||||
| Insertion | $O(n)$, $O(1)$ swap | $O(n^2)$ comp, swap | $O(n^2)$ comp, swap | Yes | Yes |
|
||||
| Merge | $O(n \log(n))$ | $O(n \log(n))$ | $O(n \log(n))$ | No | Yes |
|
||||
| Quick | $O(n \log(n))$ | $O(n \log(n))$ | $O(n^2)$ | Yes | No |
|
||||
| Counting | $O(n + k)$ | $O(n + k)$ | $O(n + k)$ |
|
||||
| Radix | $O(nk)$ | $O(nk)$ | $O(nk)$ | No | Yes |
|
||||
### Bubble
|
||||
Invariant: After `i` iterations, largest `i` elements are sorted at the back of the array
|
||||
```java
|
||||
private static void swap(int[] arr, int a, int b) {
|
||||
int tmp = arr[a]; arr[a] = arr[b]; arr[b] = tmp; }
|
||||
|
||||
static void sort(int[] input) {
|
||||
int N = input.length;
|
||||
for(; N > 0; N--) {
|
||||
for (int i = 0; i < N-1; i++) {
|
||||
if (input[i] > input[i+1]) swap(input, i, i+1);
|
||||
} } }
|
||||
```
|
||||
|
||||
### Selection
|
||||
Invariant: After `i` iterations, smallest `i` elements are sorted to the front of the array
|
||||
```java
|
||||
static void sort(int[] input) {
|
||||
for (int i = 0; i < input.length; i++) {
|
||||
int smallest = i;
|
||||
for (int j = i; j < input.length; j++) {
|
||||
if (input[smallest] > input[j]) smallest = j;
|
||||
}
|
||||
swap(input, i, smallest); } }
|
||||
```
|
||||
### Insertion
|
||||
Invariant: At the end of kth iteration, leftmost `k` elements are sorted (but not in final correct position)
|
||||
|
||||
1. Outer loop executes N-1 times
|
||||
2. inner loop runs O(n) if arrayis reverse sorted
|
||||
|
||||
```java
|
||||
static void sort(int[] arr) {
|
||||
// iterate through each element in the array
|
||||
for (int i = 1; i < arr.length; i++) {
|
||||
int tmp = arr[i];
|
||||
if (tmp > arr[i - 1]) continue;
|
||||
int j = i;
|
||||
for(; j > 0; j--) {
|
||||
arr[j] = arr[j-1];
|
||||
if (tmp > arr[j-1]) break;
|
||||
}
|
||||
arr[j] = tmp; } }
|
||||
```
|
||||
### Merge
|
||||
1. O(N log N) performance guarentee, no matter the original ordering of input
|
||||
2. Not inplace
|
||||
3. Needs N space
|
||||
### Quick Sort
|
||||
```java
|
||||
int partition(array A, int I, int J) {
|
||||
int p = a[i];
|
||||
int m = i; // S1 and S2 are empty
|
||||
for (int k = i+1; k <=j k++) { // explore unknown
|
||||
if ((A[k] < p) || ((A[k] == p) && (rand()%2==0))) {
|
||||
++m;
|
||||
swap(A[k], A[m]); // exchange 2 values
|
||||
}
|
||||
}
|
||||
swap(A[i], A[m]); // put pivot in center
|
||||
return m; // return index of pivot
|
||||
}
|
||||
|
||||
void quickSort(array A, int low, int high) {
|
||||
if (low >= high) return;
|
||||
int m = partition(a, low, high);
|
||||
quickSort(A, low, m-1);
|
||||
quickSort(A, m+1, high);
|
||||
}
|
||||
```
|
||||
## Linked List
|
||||
|
||||
## Binary Heap
|
||||
## Union Find
|
||||
## Hash Table
|
||||
## Binary Search Trees
|
||||
## Graph Structures
|
||||
## Graph Traversal
|
||||
### Topo Sorting
|
||||
#### Lexographic Kahn's Algorithm $O(V\log(V)+E)$
|
||||
Non Lexographic Variant is O(V+E)
|
||||
```python
|
||||
from heapq import heappush, heappop
|
||||
def topoSort(AL):
|
||||
V = len(AL)
|
||||
in_deg = [0] * V # Build the indegree of each vertex
|
||||
for u in range(V):
|
||||
for w in AL[u]:
|
||||
in_deg[w] += 1
|
||||
q = [] # Push all elements with indegree 0 to be processed
|
||||
for i in range(V):
|
||||
if in_deg[i] == 0: heappush(q, i)
|
||||
result = []
|
||||
count = 0 # to check for cycles
|
||||
while q:
|
||||
u = heappop(q) # normal push / pop for non lexographic variants
|
||||
result.append(u)
|
||||
count +=1
|
||||
for w in AL[u]:
|
||||
in_deg[w] -= 1
|
||||
if in_deg[w] == 0: heappush(q, w)
|
||||
if count != V:
|
||||
return []
|
||||
return res
|
||||
```
|
||||
## Single Source Shortest Path
|
||||
### Bellman Ford Algorithm $O(V\times E)$
|
||||
```python
|
||||
def bellman_ford(AL, numV, start):
|
||||
dist = [INF for _ in range(V)]
|
||||
dist[start] = 0
|
||||
for _ in range(0, V-1):
|
||||
modified = False
|
||||
for u in range(0, V):
|
||||
if (dist[u] != INF):
|
||||
for v, w in AL[u]:
|
||||
if(dist[u]+w >= dist[v]): continue
|
||||
dist[v] = dist[u]+w
|
||||
modified = True
|
||||
if (not mofified): break
|
||||
hasNegativeCycle = False
|
||||
for _ in range(0, V):
|
||||
if (dist[u] != INF):
|
||||
for v, w in AL[u]:
|
||||
if (dist[v] > dist[u]+w): hasNegativeCycle = True
|
||||
if hasNegativeCycles: print("Negative cycles")
|
||||
for u in range(V):
|
||||
print(start, u, dist[u])
|
||||
```
|
||||
### Breadth First Search
|
||||
### Dijkstra's Algorithm $O((V+E)\log Vk)$
|
||||
#### Modified Dijkstra's Algorithm
|
||||
### Dynamic Programming
|
||||
## Minimum Spanning Tree
|
||||
### Kruskal's Algorithm $O(E\log(V))$
|
||||
If the weight of the edges is bounded, then you can use counting sort to bring the complexity down to O(E)
|
||||
```python
|
||||
def kruskalMST(EL, numV, numE): # edge list has (weight, from, to)
|
||||
EL.sort()
|
||||
UF = UnionFind(numV)
|
||||
count = 0
|
||||
cost = 0
|
||||
for i in range(E):
|
||||
if count == V-1: break
|
||||
w, u, v = EL[i]
|
||||
if (not UF.isSameSet(u, v)):
|
||||
num_taken += 1
|
||||
mst_cost += w
|
||||
UF.unionSet(u, v)
|
||||
print(cost)
|
||||
```
|
||||
### Prim's Algorithm
|
||||
```python
|
||||
def prims(AL, numV):
|
||||
pq = []
|
||||
taken = [0 for i in range(numV)]
|
||||
cost = 0
|
||||
count =0
|
||||
taken[0] = 1
|
||||
for v,w in AL[0]: heappush(pq, (w, v)) # starting elements into the heap
|
||||
while pq:
|
||||
if count = numV-1: break
|
||||
w, u = heappop(pq)
|
||||
if not taken[u]:
|
||||
taken[u] = 1
|
||||
cost += w
|
||||
count += 1
|
||||
for v, w in AL[u]:
|
||||
if not taken[v]: heappush(pq, (w, v))
|
||||
print(cost)
|
||||
```
|
160
labs/cs2102/Tutorials/T07.sql
Normal file
160
labs/cs2102/Tutorials/T07.sql
Normal file
@ -0,0 +1,160 @@
|
||||
CREATE TABLE Offices
|
||||
(
|
||||
oid INTEGER,
|
||||
address VARCHAR(60),
|
||||
PRIMARY KEY (oid)
|
||||
);
|
||||
|
||||
-- eid = eid of department 's manager
|
||||
CREATE TABLE IF NOT EXISTS Departments
|
||||
(
|
||||
did INTEGER,
|
||||
dbudget INTEGER NOT NULL,
|
||||
oid INTEGER NOT NULL,
|
||||
eid INTEGER NOT NULL, -- no FK to manager
|
||||
PRIMARY KEY (did),
|
||||
FOREIGN KEY (oid) REFERENCES Offices
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Employees
|
||||
(
|
||||
eid INTEGER,
|
||||
did INTEGER NOT NULL,
|
||||
PRIMARY KEY (eid),
|
||||
FOREIGN KEY (did) REFERENCES Departments
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Engineers
|
||||
(
|
||||
eid INTEGER,
|
||||
PRIMARY KEY (eid),
|
||||
FOREIGN KEY (eid) REFERENCES Employees
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Managers
|
||||
(
|
||||
eid INTEGER,
|
||||
PRIMARY KEY (eid),
|
||||
FOREIGN KEY (eid) REFERENCES Employees
|
||||
);
|
||||
|
||||
-- eid = eid of project's supervisor
|
||||
CREATE TABLE IF NOT EXISTS Projects
|
||||
(
|
||||
pid INTEGER,
|
||||
pbudget INTEGER NOT NULL,
|
||||
eid INTEGER NOT NULL,
|
||||
PRIMARY KEY (pid),
|
||||
FOREIGN KEY (eid) REFERENCES Managers
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS WorkType
|
||||
(
|
||||
wid INTEGER,
|
||||
max_hours INTEGER NOT NULL,
|
||||
PRIMARY KEY (wid)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Works
|
||||
(
|
||||
pid INTEGER,
|
||||
eid INTEGER,
|
||||
wid INTEGER,
|
||||
hours INTEGER NOT NULL,
|
||||
PRIMARY KEY (pid, eid),
|
||||
FOREIGN KEY (eid) REFERENCES Engineers,
|
||||
FOREIGN KEY (pid) REFERENCES Projects,
|
||||
FOREIGN KEY (wid) REFERENCES WorkType
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE OR REPLACE FUNCTION not_manager()
|
||||
RETURNS TRIGGER AS
|
||||
$$
|
||||
DECLARE
|
||||
count NUMERIC;
|
||||
BEGIN
|
||||
SELECT COUNT(*) INTO count FROM managers WHERE NEW.eid = Managers.eid;
|
||||
if count > 0 THEN RETURN NULL; ELSE RETURN NEW; END IF;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER non_manager
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON Engineers
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION not_manager();
|
||||
|
||||
CREATE OR REPLACE FUNCTION check_budget()
|
||||
RETURNS TRIGGER AS
|
||||
$$
|
||||
DECLARE
|
||||
pbudget numeric;
|
||||
curr_budget numeric;
|
||||
BEGIN
|
||||
SELECT pbudget
|
||||
INTO pbudget
|
||||
FROM projects
|
||||
WHERE pid = NEW.pid;
|
||||
|
||||
SELECT COALESCE(SUM(hours), 0) * 100
|
||||
INTO curr_budget
|
||||
FROM Works
|
||||
WHERE pid = NEW.pid
|
||||
AND eid != NEW.eid;
|
||||
if curr_budget + NEW.hours * 100 > pbudget THEN
|
||||
RETURN (NEW.pid, NEW.eid, NEW.wid, (pbudget - curr_budget) / 100);
|
||||
ELSE
|
||||
RETURN NEW;
|
||||
end if;
|
||||
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER budget_check
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON Works
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION check_budget();
|
||||
|
||||
CREATE OR REPLACE FUNCTION max_hour_work()
|
||||
RETURNS TRIGGER AS
|
||||
$$
|
||||
DECLARE
|
||||
max_hrs NUMERIC;
|
||||
BEGIN
|
||||
SELECT max_hours INTO max_hrs FROM worktype WHERE wid = NEW.wid;
|
||||
IF NEW.HOURS > max_hrs THEN
|
||||
RETURN (NEW.pid, NEW.eid, NEW.wid, max_hrs);
|
||||
ELSE
|
||||
RETURN NEW;
|
||||
END IF;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER hours_max
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON works
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION max_hour_work();
|
||||
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION wid_check()
|
||||
RETURNS TRIGGER AS
|
||||
$$
|
||||
DECLARE
|
||||
BEGIN
|
||||
RAISE NOTICE 'some user tried to';
|
||||
RAISE NOTICE 'modify/delete default';
|
||||
RAISE NOTICE 'work type';
|
||||
RETURN NULL;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER check_wid
|
||||
BEFORE UPDATE OR DELETE
|
||||
ON WorkType
|
||||
FOR EACH ROW
|
||||
WHEN (OLD.wid = 0)
|
||||
EXECUTE FUNCTION wid_check();
|
71
labs/cs2102/Tutorials/tut01.sql
Normal file
71
labs/cs2102/Tutorials/tut01.sql
Normal file
@ -0,0 +1,71 @@
|
||||
INSERT INTO book VALUES (
|
||||
'An Introduction to Database Systems',
|
||||
'paperback' ,
|
||||
640 ,
|
||||
'English' ,
|
||||
'C. J. Date' ,
|
||||
'Pearson',
|
||||
'0321197844' ,
|
||||
'978-0321197849');
|
||||
|
||||
|
||||
INSERT INTO student VALUES (
|
||||
'TIKKI TAVI' ,
|
||||
'tikki@gmail.com' ,
|
||||
'2021-08-01',
|
||||
'School of Computing',
|
||||
'CS',
|
||||
NULL);
|
||||
|
||||
INSERT INTO student (email, name, year, faculty, department)
|
||||
VALUES (
|
||||
'rikki@gmail.com',
|
||||
'RIKKI TAVI',
|
||||
'2021-08-01',
|
||||
'School of Computing',
|
||||
'CS');
|
||||
|
||||
|
||||
UPDATE student
|
||||
SET department = 'Computer Science'
|
||||
WHERE department = 'CS';
|
||||
|
||||
-- Does not work as students references loans
|
||||
-- DELETE FROM student WHERE department = 'Chemistry';
|
||||
|
||||
-- remove foreign key constraint
|
||||
ALTER TABLE loan DROP CONSTRAINT loan_borrower_fkey;
|
||||
-- add new foreign key constraint
|
||||
ALTER TABLE loan ADD CONSTRAINT loan_borrower_fkey
|
||||
FOREIGN KEY (borrower) REFERENCES student(email) ON DELETE CASCADE DEFERRABLE INITIALLY IMMEDIATE ;
|
||||
DELETE FROM student where department = 'Chemistry';
|
||||
|
||||
INSERT INTO copy
|
||||
VALUES (
|
||||
'tikki@gmail.com',
|
||||
'978-0321197849',
|
||||
1);
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
SET CONSTRAINTS ALL IMMEDIATE;
|
||||
DELETE FROM book
|
||||
WHERE ISBN13 = '978-0321197849' ;
|
||||
DELETE FROM copy
|
||||
WHERE book = '978-0321197849' ;
|
||||
END TRANSACTION;
|
||||
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
SET CONSTRAINTS ALL DEFERRED;
|
||||
DELETE FROM book WHERE ISBN13 = '978-0321197849' ;
|
||||
DELETE FROM copy WHERE book = '978-0321197849' ;
|
||||
END TRANSACTION;
|
||||
|
||||
|
||||
ALTER TABLE copy ADD COLUMN available BOOLEAN DEFAULT true;
|
||||
|
||||
UPDATE copy
|
||||
SET available = false
|
||||
WHERE (owner, book, copy) IN (SELECT owner, book, copy FROM loan WHERE returned ISNULL);
|
||||
|
||||
-- Disagree, the departments and fields are not the same.
|
90
labs/cs2102/Tutorials/tut03.sql
Normal file
90
labs/cs2102/Tutorials/tut03.sql
Normal file
@ -0,0 +1,90 @@
|
||||
|
||||
-- 1a
|
||||
SELECT distinct s.department
|
||||
FROM student s;
|
||||
|
||||
-- Print the different departments in which students are enrolled
|
||||
select distinct department
|
||||
from student;
|
||||
|
||||
-- Email of students who borrowed or lent copy before uni
|
||||
SELECT DISTINCT s.email
|
||||
FROM student s, loan l
|
||||
WHERE (s.email = l.borrower OR s.email = l.owner) AND s.year > l.borrowed;
|
||||
|
||||
-- For each copy borrowed / returned, print duration. Order in ASC ISBN13 and desc duration
|
||||
SELECT l.returned - l.borrowed as duration, l.book
|
||||
FROM loan l
|
||||
WHERE returned IS NOT NULL
|
||||
order by l.book ASC, duration DESC;
|
||||
|
||||
-- For each book published by wiley that has not been returned ,print title, name, faculty, (name, faculty of borrower)
|
||||
select b.title,
|
||||
owner.name,
|
||||
owner.faculty,
|
||||
borrower.name,
|
||||
borrower.faculty
|
||||
from loan l,
|
||||
book b,
|
||||
student owner, student borrower
|
||||
WHERE b.isbn13 = l.book
|
||||
AND owner.email = l.owner
|
||||
AND borrower.email = l.borrower
|
||||
AND b.publisher = 'Wiley'
|
||||
AND returned is null;
|
||||
|
||||
-- For each book published by wiley that has not been returned ,print title, name, faculty, (name, faculty of borrower)select b.title, owner.name, owner.faculty, borrower.name, borrower.faculty
|
||||
SELECT b.title,
|
||||
owner.name,
|
||||
owner.faculty,
|
||||
borrower.name,
|
||||
borrower.faculty
|
||||
FROM loan l
|
||||
INNER JOIN book b on b.isbn13 = l.book
|
||||
INNER JOIN student owner on owner.email = l.owner
|
||||
INNER JOIN student borrower on borrower.email = l.borrower
|
||||
WHERE b.publisher = 'Wiley'
|
||||
AND returned is null;
|
||||
|
||||
|
||||
-- Print email of different studnt who borrowed or lent a book on the day they joined uni
|
||||
SELECT s.email
|
||||
FROM loan l, student s
|
||||
WHERE s.email = l.borrower AND l.borrowed = s.year
|
||||
UNION
|
||||
SELECT s.email
|
||||
FROM loan l, student s
|
||||
WHERE s.email = l.owner AND l.borrowed = s.year;
|
||||
|
||||
-- OR
|
||||
SELECT DISTINCT s.email
|
||||
FROM loan l, student s
|
||||
WHERE (s.email = l.borrower OR s.email = l.owner)
|
||||
AND l.borrowed = s.year;
|
||||
|
||||
-- Print email of different studnt who borrowed or lent a book on the day they joined uni
|
||||
SELECT s.email
|
||||
FROM loan l, student s
|
||||
WHERE s.email = l.borrower AND l.borrowed = s.year
|
||||
INTERSECT
|
||||
SELECT s.email
|
||||
FROM loan l, student s
|
||||
WHERE s.email = l.owner AND l.borrowed = s.year;
|
||||
-- Print the emails of the students who borrowed but did not lend a copy of a book on the day that they joined the university
|
||||
SELECT s.email
|
||||
FROM loan l, student s
|
||||
WHERE s.email = l.borrower AND l.borrowed = s.year
|
||||
EXCEPT
|
||||
SELECT s.email
|
||||
FROM loan l, student s
|
||||
WHERE s.email = l.owner AND l.borrowed = s.year;
|
||||
-- Print the ISBN13 of the books (not the copies) that have never been borrowed
|
||||
SELECT b.ISBN13
|
||||
FROM book b
|
||||
EXCEPT
|
||||
SELECT l.book
|
||||
FROM loan l;
|
||||
|
||||
SELECT b.ISBN13
|
||||
FROM book b LEFT OUTER JOIN loan l ON b.isbn13 = l.book
|
||||
WHERE l.book IS NULL;
|
79
labs/cs2102/Tutorials/tut06-ans.sql
Normal file
79
labs/cs2102/Tutorials/tut06-ans.sql
Normal file
@ -0,0 +1,79 @@
|
||||
CREATE OR REPLACE FUNCTION max_min(IN stu_id INT, OUT max_cid INT, OUT min_cid INT)
|
||||
RETURNS RECORD AS
|
||||
$$
|
||||
DECLARE
|
||||
max_score INT;
|
||||
min_score INT;
|
||||
BEGIN
|
||||
SELECT e.score, e.cid
|
||||
INTO max_score, max_cid
|
||||
FROM exams e
|
||||
WHERE stu_id = e.sid
|
||||
AND e.score = (SELECT MAX(score)
|
||||
FROM exams
|
||||
where stu_id = sid);
|
||||
SELECT e.score, e.cid
|
||||
INTO min_score, min_cid
|
||||
FROM exams e
|
||||
WHERE stu_id = e.sid
|
||||
AND e.score = (SELECT MIN(score)
|
||||
FROM exams
|
||||
where stu_id = sid);
|
||||
|
||||
IF max_score = min_score THEN
|
||||
min_cid = NULL;
|
||||
END IF;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION revised_avg(IN stu_id INT, OUT r_avg FLOAT)
|
||||
RETURNS FLOAT AS
|
||||
$$
|
||||
DECLARE
|
||||
max_score INT;
|
||||
min_score INT;
|
||||
sum_score FLOAT;
|
||||
count_score INT;
|
||||
BEGIN
|
||||
SELECT MAX(score), MIN(score), SUM(score), COUNT(score)
|
||||
INTO max_score, min_score, sum_score, count_score
|
||||
FROM exams
|
||||
WHERE sid = stu_id;
|
||||
|
||||
if count_score < 3 THEN
|
||||
r_avg := NULL;
|
||||
ELSE
|
||||
r_avg := (sum_score - max_score - min_score) / (count_score - 2);
|
||||
end if;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION list_r_avg()
|
||||
RETURNS TABLE
|
||||
(
|
||||
stu_id INT,
|
||||
ravg FLOAT
|
||||
)
|
||||
AS
|
||||
$$
|
||||
DECLARE
|
||||
curs CURSOR FOR (SELECT sid, score
|
||||
FROM Exams
|
||||
ORDER BY sid);
|
||||
r RECORD;
|
||||
/* add other variables here */
|
||||
BEGIN
|
||||
/* write your code here */
|
||||
stu_id := -1;
|
||||
OPEN curs;
|
||||
LOOP
|
||||
FETCH curs INTO r;
|
||||
if r.sid <> "".stu_idOR NOT FOUND THEN
|
||||
|
||||
end if;
|
||||
|
||||
end loop;
|
||||
CLOSE curs;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
151
labs/cs2102/Tutorials/tut06.sql
Normal file
151
labs/cs2102/Tutorials/tut06.sql
Normal file
@ -0,0 +1,151 @@
|
||||
DROP TABLE IF EXISTS exams;
|
||||
CREATE TABLE IF NOT EXISTS
|
||||
exams
|
||||
(
|
||||
SID INT,
|
||||
CID INT,
|
||||
score INT,
|
||||
PRIMARY KEY (SID, CID)
|
||||
);
|
||||
|
||||
CREATE OR REPLACE FUNCTION max_min(IN stu_id INT, OUT max_cid INT, OUT min_cid INT)
|
||||
RETURNS RECORD AS
|
||||
$$
|
||||
DECLARE
|
||||
max_score INT; min_score INT;
|
||||
BEGIN
|
||||
SELECT e.score, e.cid
|
||||
INTO max_cid, max_score
|
||||
FROM exams e
|
||||
WHERE e.sid = stu_id
|
||||
AND e.score = (SELECT MAX(score) from exams);
|
||||
|
||||
SELECT e.score, e.cid
|
||||
INTO min_cid, min_score
|
||||
FROM exams e
|
||||
WHERE e.sid = stu_id
|
||||
AND e.score = (SELECT MIN(score) from exams);
|
||||
IF min_score = max_score THEN
|
||||
min_cid := NULL;
|
||||
end if;
|
||||
/* write your code here */
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION revised_avg(IN stu_id INT, OUT r_avg FLOAT)
|
||||
RETURNS FLOAT AS
|
||||
$$
|
||||
DECLARE
|
||||
max_score INT;
|
||||
min_score INT;
|
||||
count_score INT;
|
||||
sum_score INT;
|
||||
BEGIN
|
||||
SELECT MAX(score), MIN(score), COUNT(score), SUM(score)
|
||||
INTO max_score, min_score, count_score, sum_score
|
||||
FROM exams;
|
||||
|
||||
IF count_score < 3 THEN
|
||||
r_avg := NULL;
|
||||
ELSE
|
||||
r_avg := (sum_score - min_score - max_score) / (count_score - 2);
|
||||
END IF;
|
||||
END;
|
||||
/* write your code here */
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION list_r_avg()
|
||||
RETURNS TABLE
|
||||
(
|
||||
stu_id INT,
|
||||
ravg FLOAT
|
||||
)
|
||||
AS
|
||||
$$
|
||||
DECLARE
|
||||
curs CURSOR FOR (SELECT sid, score
|
||||
FROM Exams
|
||||
ORDER BY sid);
|
||||
curr RECORD;
|
||||
sum_score INT;
|
||||
count_score INT;
|
||||
max_score INT;
|
||||
min_score INT;
|
||||
/* add other variables here */
|
||||
BEGIN
|
||||
-- to validate first row
|
||||
stu_id := -1;
|
||||
OPEN curs;
|
||||
LOOP
|
||||
FETCH curs INTO curr;
|
||||
IF curr.sid != stu_id OR NOT FOUND THEN
|
||||
IF stu_id != -1 THEN
|
||||
IF (count_score < 3) THEN
|
||||
ravg := NULL;
|
||||
ELSE
|
||||
ravg := (sum_score - max_score - min_score) / (count_score - 2);
|
||||
END IF;
|
||||
RETURN NEXT;
|
||||
END IF;
|
||||
EXIT WHEN NOT FOUND;
|
||||
stu_id := curr.sid;
|
||||
max_score := curr.score;
|
||||
min_score := curr.score;
|
||||
sum_score := curr.score;
|
||||
count_score := 1;
|
||||
ELSE
|
||||
sum_score := curr.score + sum_score;
|
||||
count_score := count_score + 1;
|
||||
IF max_score < curr.score THEN max_score := curr.score; END IF;
|
||||
IF min_score > curr.score THEN min_score := curr.score; END IF;
|
||||
END IF;
|
||||
END LOOP;
|
||||
CLOSE curs;
|
||||
/* write your code here */
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION list_scnd_highest()
|
||||
RETURNS TABLE
|
||||
(
|
||||
stu_id INT,
|
||||
scnd_highest INT
|
||||
)
|
||||
AS
|
||||
$$
|
||||
DECLARE
|
||||
curs CURSOR FOR (SELECT sid, score
|
||||
FROM Exams
|
||||
ORDER BY sid);
|
||||
curr RECORD;
|
||||
max_score INT;
|
||||
count_score INT;
|
||||
BEGIN
|
||||
stu_id := -1;
|
||||
OPEN curs;
|
||||
LOOP
|
||||
FETCH curs INTO curr;
|
||||
IF curr.sid != stu_id OR NOT FOUND THEN
|
||||
IF stu_id <> -1 THEN
|
||||
IF (count_score < 2) THEN scnd_highest := NULL; END IF;
|
||||
RETURN NEXT;
|
||||
end if;
|
||||
EXIT WHEN NOT FOUND;
|
||||
stu_id := curr.sid;
|
||||
max_score := curr.score;
|
||||
scnd_highest := -1;
|
||||
count_score := 1;
|
||||
ELSE
|
||||
IF curr.score > max_score THEN
|
||||
scnd_highest := max_score;
|
||||
max_score := curr.score;
|
||||
ELSEIF curr.score > scnd_highest THEN
|
||||
scnd_highest := curr.score;
|
||||
END IF;
|
||||
count_score := count_score + 1;
|
||||
END IF;
|
||||
END LOOP;
|
||||
CLOSE curs;
|
||||
RETURN;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
@ -0,0 +1,209 @@
|
||||
-- Q1 (Correct)
|
||||
-- Which riders ride for teams of their own country?
|
||||
SELECT r.bib AS bib,
|
||||
r.name AS name,
|
||||
t.name AS team_name,
|
||||
t.country AS country
|
||||
FROM riders r,
|
||||
teams t
|
||||
WHERE r.team = t.name
|
||||
AND t.country = r.country;
|
||||
|
||||
-- Q2 (Correct)
|
||||
-- Which stages started and ended in different countries?
|
||||
SELECT s.nr AS stage_nr,
|
||||
l1.country as cc_start,
|
||||
l2.country as cc_end
|
||||
FROM stages s,
|
||||
locations l1,
|
||||
locations l2
|
||||
WHERE s.start = l1.name
|
||||
AND s.finish = l2.name
|
||||
AND l1.country != l2.country;
|
||||
|
||||
-- Q3 (Correct)
|
||||
-- Which stages featured the highest mountains? Sort from highest to lowest max_height
|
||||
SELECT m.stage AS stage_nr,
|
||||
MAX(m.height) AS max_height
|
||||
FROM mountains m
|
||||
GROUP BY stage_nr
|
||||
ORDER BY max_height DESC;
|
||||
|
||||
-- Q4
|
||||
-- Which stages ended with a mountain finish?
|
||||
SELECT s.nr as stage_nr,
|
||||
m.category AS category,
|
||||
m.percent AS percent
|
||||
FROM stages s,
|
||||
mountains m
|
||||
WHERE m.location LIKE concat('%', s.finish, '%')
|
||||
ORDER BY category DESC,
|
||||
percent DESC;
|
||||
|
||||
-- Q4 (CORRECT)
|
||||
SELECT
|
||||
t.nr AS stage_nr,
|
||||
CASE
|
||||
WHEN t.category = 5 THEN 'H'
|
||||
ELSE t.category::TEXT
|
||||
END AS category,
|
||||
t.percent AS percent
|
||||
FROM (
|
||||
SELECT
|
||||
nr,
|
||||
CASE
|
||||
WHEN m.category = 'H' THEN 5
|
||||
ELSE m.category::integer
|
||||
END as category,
|
||||
m.percent
|
||||
FROM stages s, mountains m
|
||||
WHERE s.nr = m.stage
|
||||
AND s.length = m.distance
|
||||
ORDER BY m.category DESC, m.percent DESC
|
||||
) t;
|
||||
|
||||
-- Q5 (Correct)
|
||||
SELECT COUNT(*) AS num_stages
|
||||
FROM stages s1,
|
||||
stages s2
|
||||
WHERE s1.type = 'flat'
|
||||
AND s2.nr = s1.nr + 1
|
||||
AND s2.type = 'hilly';
|
||||
|
||||
-- Q6
|
||||
SELECT r.name AS name,
|
||||
SUM(rs.time - rs.bonus + rs.penalty) AS total_time
|
||||
FROM riders r,
|
||||
results_individual rs
|
||||
WHERE r.bib = rs.rider
|
||||
GROUP BY r.bib
|
||||
HAVING COUNT(rs.rider) = ALL (SELECT COUNT(*) from stages)
|
||||
ORDER BY total_time ASC
|
||||
LIMIT 10;
|
||||
|
||||
-- Q6 (CORRECT)
|
||||
SELECT r.name AS name,
|
||||
SUM(rs.time - rs.bonus + rs.penalty) AS total_time
|
||||
FROM riders r,
|
||||
results_individual rs
|
||||
WHERE r.bib = rs.rider
|
||||
AND r.bib IN (
|
||||
SELECT rider
|
||||
FROM results_individual
|
||||
WHERE stage = (SELECT MAX(nr) FROM stages)
|
||||
)
|
||||
GROUP BY r.bib
|
||||
ORDER BY total_time ASC
|
||||
LIMIT 10;
|
||||
|
||||
|
||||
|
||||
-- Q7 (Correct)
|
||||
SELECT r.name AS name,
|
||||
ROUND(SUM(s.length)/ (SUM(rs.time::NUMERIC) / 3600.00), 2) as avg_speed
|
||||
FROM riders r,
|
||||
results_individual rs,
|
||||
stages s
|
||||
WHERE r.bib = rs.rider
|
||||
AND s.nr = rs.stage
|
||||
GROUP BY r.bib
|
||||
ORDER BY avg_speed desc;
|
||||
|
||||
-- Q8
|
||||
WITH CumulativePoints AS (
|
||||
SELECT r.name AS name,
|
||||
s.day AS race_day,
|
||||
s.nr AS stage,
|
||||
SUM(COALESCE(rs.points, 0))
|
||||
OVER (PARTITION BY r.bib ORDER BY s.nr) AS points
|
||||
FROM stages s
|
||||
CROSS JOIN riders r
|
||||
LEFT JOIN results_sprints rs ON rs.stage = s.nr AND r.bib = rs.rider
|
||||
)
|
||||
SELECT DISTINCT cp.race_day,cp.name
|
||||
FROM CumulativePoints cp
|
||||
WHERE cp.points >= ALL (
|
||||
SELECT MAX(cp1.points)
|
||||
FROM CumulativePoints cp1
|
||||
WHERE cp1.stage = cp.stage
|
||||
GROUP BY cp1.stage
|
||||
)
|
||||
ORDER BY cp.race_day;
|
||||
|
||||
-- Q8 (Correct)
|
||||
SELECT s.day AS race_day, r.name
|
||||
FROM riders r, results_sprints rs, stages s
|
||||
WHERE r.bib = rs.rider
|
||||
AND rs.stage <= s.nr
|
||||
GROUP BY r.bib, r.name, s.nr
|
||||
HAVING SUM(rs.points) >= ALL(
|
||||
SELECT SUM(rs1.points)
|
||||
FROM riders r1, results_sprints rs1, stages s1
|
||||
WHERE r1.bib = rs1.rider
|
||||
AND rs1.stage <= s1.nr
|
||||
AND s1.nr = s.nr
|
||||
GROUP BY r1.bib, s1.nr
|
||||
)
|
||||
ORDER BY s.nr;
|
||||
|
||||
-- Q9
|
||||
SELECT s.day AS race_day
|
||||
FROM
|
||||
results_individual ri,
|
||||
riders r,
|
||||
stages s
|
||||
WHERE ri.rider = r.bib
|
||||
AND ri.stage = s.nr
|
||||
AND ri.rank <=50
|
||||
GROUP BY s.day
|
||||
HAVING COUNT(DISTINCT r.team) = (SELECT COUNT(*) from teams)
|
||||
ORDER BY race_day;
|
||||
|
||||
-- Q9 CORRECT
|
||||
SELECT s.day AS race_day
|
||||
FROM stages s
|
||||
WHERE NOT EXISTS(
|
||||
SELECT *
|
||||
FROM teams t
|
||||
WHERE NOT EXISTS(
|
||||
SELECT *
|
||||
FROM results_individual ri, riders r
|
||||
WHERE t.name = r.team
|
||||
AND r.bib = ri.rider
|
||||
AND ri.rank <= 50
|
||||
AND ri.stage = s.nr
|
||||
)
|
||||
);
|
||||
|
||||
-- Q10
|
||||
WITH ranked AS (
|
||||
SELECT r.team,
|
||||
SUM(ri.time + ri.penalty - ri.bonus) AS cum_time,
|
||||
row_number() over (partition by r.team order by SUM(ri.time + ri.penalty - ri.bonus) asc) as rank
|
||||
FROM riders r, results_individual ri
|
||||
WHERE ri.rider = r.bib
|
||||
group by r.team, r.name
|
||||
having COUNT(*) = (SELECT COUNT(*) FROM stages)
|
||||
)
|
||||
SELECT ranked.team AS team_name
|
||||
FROM ranked
|
||||
WHERE ranked.rank < 4
|
||||
GROUP BY ranked.team
|
||||
ORDER BY AVG(ranked.cum_time) ASC
|
||||
LIMIT 1;
|
||||
|
||||
-- Q10 (Correct)
|
||||
SELECT r.team AS team_name
|
||||
FROM (
|
||||
SELECT r.bib, r.team, r.sum,
|
||||
row_number() OVER (PARTITION BY r.team ORDER BY r.sum ASC) AS row
|
||||
FROM (SELECT r1.bib, r1.team, SUM(ri.time + ri.bonus - ri.penalty) AS sum
|
||||
FROM riders r1, results_individual ri
|
||||
WHERE r1.bib = ri.rider
|
||||
GROUP BY r1.bib
|
||||
HAVING COUNT(*) = ALL (SELECT COUNT(*) FROM stages)) as r
|
||||
) AS r
|
||||
WHERE r.row < 4
|
||||
GROUP BY r.team
|
||||
ORDER BY SUM(r.sum) ASC
|
||||
LIMIT 1;
|
17
labs/cs2102/cases/Assessment DB/01-tdfdb-clean.sql
Normal file
17
labs/cs2102/cases/Assessment DB/01-tdfdb-clean.sql
Normal file
@ -0,0 +1,17 @@
|
||||
/*******************
|
||||
Cleaning script
|
||||
*******************/
|
||||
|
||||
DROP TABLE IF EXISTS results_individual;
|
||||
DROP TABLE IF EXISTS results_sprints;
|
||||
DROP TABLE IF EXISTS results_mountains;
|
||||
DROP TABLE IF EXISTS results_combative;
|
||||
DROP TABLE IF EXISTS sprints;
|
||||
DROP TABLE IF EXISTS mountains;
|
||||
DROP TABLE IF EXISTS stages;
|
||||
DROP TABLE IF EXISTS locations;
|
||||
DROP TABLE IF EXISTS riders;
|
||||
DROP TABLE IF EXISTS teams;
|
||||
DROP TABLE IF EXISTS countries;
|
||||
DROP TABLE IF EXISTS subregions;
|
||||
DROP TABLE IF EXISTS regions;
|
130
labs/cs2102/cases/Assessment DB/02-tdfdb-schema.sql
Normal file
130
labs/cs2102/cases/Assessment DB/02-tdfdb-schema.sql
Normal file
@ -0,0 +1,130 @@
|
||||
/*******************
|
||||
Create the schema
|
||||
********************/
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS regions (
|
||||
name VARCHAR(32) PRIMARY KEY
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS subregions (
|
||||
name VARCHAR(32) PRIMARY KEY,
|
||||
region VARCHAR(32) NOT NULL,
|
||||
CONSTRAINT fk_region FOREIGN KEY (region) REFERENCES regions (name)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS countries (
|
||||
code CHAR(3) PRIMARY KEY,
|
||||
name VARCHAR(64) UNIQUE NOT NULL,
|
||||
subregion VARCHAR(32) NOT NULL,
|
||||
CONSTRAINT fk_subregion FOREIGN KEY (subregion) REFERENCES subregions (name)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS teams (
|
||||
name VARCHAR(64) PRIMARY KEY,
|
||||
country CHAR(3) NOT NULL,
|
||||
CONSTRAINT fk_country FOREIGN KEY (country) REFERENCES countries (code) ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS riders (
|
||||
bib INTEGER PRIMARY KEY,
|
||||
name VARCHAR(64) NOT NULL,
|
||||
dob DATE NOT NULL,
|
||||
country CHAR(3) NOT NULL,
|
||||
team VARCHAR(64) NOT NULL,
|
||||
CONSTRAINT fk_team FOREIGN KEY (team) REFERENCES teams (name) ON UPDATE CASCADE,
|
||||
CONSTRAINT fk_country FOREIGN KEY (country) REFERENCES countries (code) ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS locations (
|
||||
name VARCHAR(64) PRIMARY KEY,
|
||||
country CHAR(3) NOT NULL,
|
||||
CONSTRAINT fk_country FOREIGN KEY (country) REFERENCES countries (code) ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS stages (
|
||||
nr INTEGER PRIMARY KEY,
|
||||
day DATE UNIQUE NOT NULL,
|
||||
start VARCHAR(64) NOT NULL,
|
||||
finish VARCHAR(64) NOT NULL,
|
||||
length NUMERIC(5,1) NOT NULL,
|
||||
type VARCHAR(32),
|
||||
CONSTRAINT fk_start FOREIGN KEY (start) REFERENCES locations (name) ON UPDATE CASCADE,
|
||||
CONSTRAINT fk_finish FOREIGN KEY (finish) REFERENCES locations (name) ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sprints (
|
||||
stage INTEGER NOT NULL,
|
||||
location VARCHAR(64) NOT NULL,
|
||||
distance NUMERIC(5,1) NOT NULL,
|
||||
PRIMARY KEY (stage, location),
|
||||
CONSTRAINT fk_stage FOREIGN KEY (stage) REFERENCES stages (nr) ON UPDATE CASCADE,
|
||||
CONSTRAINT fk_location FOREIGN KEY (location) REFERENCES locations (name) ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS mountains (
|
||||
stage INTEGER NOT NULL,
|
||||
location VARCHAR(64) NOT NULL,
|
||||
distance NUMERIC(5,1) NOT NULL,
|
||||
height NUMERIC(5,1) NOT NULL,
|
||||
length NUMERIC(3,1) NOT NULL,
|
||||
percent NUMERIC(3,1) NOT NULL,
|
||||
category CHAR(1) NOT NULL,
|
||||
PRIMARY KEY (stage, location),
|
||||
CONSTRAINT fk_stage FOREIGN KEY (stage) REFERENCES stages (nr) ON UPDATE CASCADE,
|
||||
CONSTRAINT fk_location FOREIGN KEY (location) REFERENCES locations (name) ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS results_individual (
|
||||
stage INTEGER NOT NULL,
|
||||
rank INTEGER NOT NULL CHECK (rank > 0),
|
||||
rider INTEGER NOT NULL,
|
||||
time INTEGER NOT NULL CHECK (time >= 0),
|
||||
bonus INTEGER NOT NULL DEFAULT 0 CHECK (bonus >= 0),
|
||||
penalty INTEGER NOT NULL DEFAULT 0 CHECK (penalty >= 0),
|
||||
CONSTRAINT fk_stage FOREIGN KEY (stage) REFERENCES stages (nr) ON UPDATE CASCADE,
|
||||
CONSTRAINT fk_rider FOREIGN KEY (rider) REFERENCES riders (bib) ON UPDATE CASCADE,
|
||||
CONSTRAINT pk_result_individual PRIMARY KEY (stage, rank, rider)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS results_sprints (
|
||||
stage INTEGER NOT NULL,
|
||||
location VARCHAR(64) NOT NULL,
|
||||
rank INTEGER NOT NULL CHECK (rank > 0),
|
||||
rider INTEGER NOT NULL,
|
||||
points INTEGER NOT NULL CHECK (points > 0),
|
||||
CONSTRAINT fk_sprint FOREIGN KEY (stage, location) REFERENCES sprints (stage, location) ON UPDATE CASCADE,
|
||||
CONSTRAINT fk_rider FOREIGN KEY (rider) REFERENCES riders (bib) ON UPDATE CASCADE,
|
||||
CONSTRAINT pk_result_sprint PRIMARY KEY (stage, location, rank, rider)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS results_mountains (
|
||||
stage INTEGER NOT NULL,
|
||||
location VARCHAR(64) NOT NULL,
|
||||
rank INTEGER NOT NULL CHECK (rank > 0),
|
||||
rider INTEGER NOT NULL,
|
||||
points INTEGER NOT NULL CHECK (points > 0),
|
||||
CONSTRAINT fk_mountain FOREIGN KEY (stage, location) REFERENCES mountains (stage, location) ON UPDATE CASCADE,
|
||||
CONSTRAINT fk_rider FOREIGN KEY (rider) REFERENCES riders (bib) ON UPDATE CASCADE,
|
||||
CONSTRAINT pk_result_mountain PRIMARY KEY (stage, location, rank, rider)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS results_combative (
|
||||
stage INTEGER NOT NULL,
|
||||
rider INTEGER NOT NULL,
|
||||
CONSTRAINT fk_stage FOREIGN KEY (stage) REFERENCES stages (nr) ON UPDATE CASCADE,
|
||||
CONSTRAINT fk_rider FOREIGN KEY (rider) REFERENCES riders (bib) ON UPDATE CASCADE,
|
||||
CONSTRAINT pk_winner PRIMARY KEY (stage, rider)
|
||||
);
|
5092
labs/cs2102/cases/Assessment DB/03-tdfdb-data.sql
Normal file
5092
labs/cs2102/cases/Assessment DB/03-tdfdb-data.sql
Normal file
File diff suppressed because it is too large
Load Diff
106
labs/cs2102/cases/Assessment DB/04-tdfdb-check.sql
Normal file
106
labs/cs2102/cases/Assessment DB/04-tdfdb-check.sql
Normal file
@ -0,0 +1,106 @@
|
||||
/*******************
|
||||
Check database
|
||||
********************/
|
||||
|
||||
DO
|
||||
$$
|
||||
DECLARE
|
||||
table_count INTEGER = 0;
|
||||
BEGIN
|
||||
|
||||
SELECT COUNT(*) INTO table_count FROM regions; -- 5
|
||||
IF table_count = 5 THEN
|
||||
RAISE NOTICE 'Table "regions": OK (% rows)', table_count;
|
||||
ELSE
|
||||
RAISE NOTICE 'Table "regions": FAIL (% instead of 5 rows)', table_count;
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO table_count FROM subregions; -- 17
|
||||
IF table_count = 17 THEN
|
||||
RAISE NOTICE 'Table "subregions": OK (% rows)', table_count;
|
||||
ELSE
|
||||
RAISE NOTICE 'Table "subregions": FAIL (% instead of 17 rows)', table_count;
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO table_count FROM countries; -- 226
|
||||
IF table_count = 226 THEN
|
||||
RAISE NOTICE 'Table "countries": OK (% rows)', table_count;
|
||||
ELSE
|
||||
RAISE NOTICE 'Table "countries": FAIL (% instead of 226 rows)', table_count;
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO table_count FROM teams; -- 22
|
||||
IF table_count = 22 THEN
|
||||
RAISE NOTICE 'Table "teams": OK (% rows)', table_count;
|
||||
ELSE
|
||||
RAISE NOTICE 'Table "teams": FAIL (% instead of 22 rows)', table_count;
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO table_count FROM riders; -- 176
|
||||
IF table_count = 176 THEN
|
||||
RAISE NOTICE 'Table "riders": OK (% rows)', table_count;
|
||||
ELSE
|
||||
RAISE NOTICE 'Table "riders": FAIL (% instead of 176 rows)', table_count;
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO table_count FROM locations; -- 132
|
||||
IF table_count = 132 THEN
|
||||
RAISE NOTICE 'Table "locations": OK (% rows)', table_count;
|
||||
ELSE
|
||||
RAISE NOTICE 'Table "locations": FAIL (% instead of 132 rows)', table_count;
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO table_count FROM sprints; -- 40
|
||||
IF table_count = 40 THEN
|
||||
RAISE NOTICE 'Table "sprints": OK (% rows)', table_count;
|
||||
ELSE
|
||||
RAISE NOTICE 'Table "sprints": FAIL (% instead of 40 rows)', table_count;
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO table_count FROM mountains; -- 70
|
||||
IF table_count = 70 THEN
|
||||
RAISE NOTICE 'Table "mountains": OK (% rows)', table_count;
|
||||
ELSE
|
||||
RAISE NOTICE 'Table "mountains": FAIL (% instead of 70 rows)', table_count;
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO table_count FROM stages; -- 21
|
||||
IF table_count = 21 THEN
|
||||
RAISE NOTICE 'Table "stages": OK (% rows)', table_count;
|
||||
ELSE
|
||||
RAISE NOTICE 'Table "stages": FAIL (% instead of 21 rows)', table_count;
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO table_count FROM results_individual; -- 3449
|
||||
IF table_count = 3449 THEN
|
||||
RAISE NOTICE 'Table "results_individual": OK (% rows)', table_count;
|
||||
ELSE
|
||||
RAISE NOTICE 'Table "results_individual": FAIL (% instead of 3449 rows)', table_count;
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO table_count FROM results_sprints; -- 600
|
||||
IF table_count = 600 THEN
|
||||
RAISE NOTICE 'Table "results_sprints": OK (% rows)', table_count;
|
||||
ELSE
|
||||
RAISE NOTICE 'Table "results_sprints": FAIL (% instead of 600 rows)', table_count;
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO table_count FROM results_mountains; -- 233
|
||||
IF table_count = 233 THEN
|
||||
RAISE NOTICE 'Table "results_mountains": OK (% rows)', table_count;
|
||||
ELSE
|
||||
RAISE NOTICE 'Table "results_mountains": FAIL (% instead of 233 rows)', table_count;
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO table_count FROM results_combative; -- 19
|
||||
IF table_count = 19 THEN
|
||||
RAISE NOTICE 'Table "results_combative": OK (% rows)', table_count;
|
||||
ELSE
|
||||
RAISE NOTICE 'Table "results_combative": FAIL (% instead of 19 rows)', table_count;
|
||||
END IF;
|
||||
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
|
||||
|
Binary file not shown.
393
labs/cs2102/cases/Book Exchange/NUNStABook.sql
Normal file
393
labs/cs2102/cases/Book Exchange/NUNStABook.sql
Normal file
@ -0,0 +1,393 @@
|
||||
/************************
|
||||
|
||||
Populate the book table
|
||||
|
||||
*************************/
|
||||
|
||||
INSERT INTO book VALUES ('Photoshop Elements 9: The Missing Manual','paperback',640,'English','Barbara Brundage','Pogue Press','1449389678','978-1449389673');
|
||||
INSERT INTO book VALUES ('Where Good Ideas Come From: The Natural History of Innovation','paperback',336,'English','Steven Johnson','Riverhead Hardcover','1594487715','978-1594487712');
|
||||
INSERT INTO book VALUES ('The Digital Photography Book','paperback',219,'English','Scott Kelby','Peachpit Press','032147404X','978-0321474049');
|
||||
INSERT INTO book VALUES ('The Great Gatsby','paperback',216,'English','F. Scott Fitzgerald','Scribner','0684801523','978-0684801520');
|
||||
INSERT INTO book VALUES ('Davis s Drug Guide For Nurses (book With Cd-rom) And Mednotes: Nurse s Pocket Pharmacology Guide','paperback',1482,'English','Judith Hopfer Deglin, April Hazard Vallerand','F. A. Davis Company','0803612257','978-0803612259');
|
||||
INSERT INTO book VALUES ('Microsoft Office 2007: Introductory Concepts and Techniques, Premium Video Edition (Book Only)','paperback',1368,'English','Gary B. Shelly, Thomas J. Cashman, Misty E. Vermaat','Course Technology','1111529027','978-1111529024');
|
||||
INSERT INTO book VALUES ('The Future of Learning Institutions in a Digital Age (John D. and Catherine T. MacArthur Foundation Reports on Digital Media and Learning)','paperback',81,'English','Cathy N. Davidson, David Theo Goldberg','The MIT Press ','0262513595','978-0262513593');
|
||||
INSERT INTO book VALUES ('The New Rules of Marketing and PR: How to Use Social Media, Blogs, News Releases, Online Video, and Viral Marketing to Reach Buyers Directly, 2nd Edition','paperback',320,'English','David Meerman Scott','Wiley','0470547812','978-0470547816');
|
||||
INSERT INTO book VALUES ('Dont Make Me Think: A Common Sense Approach to Web Usability, 2nd Edition','paperback',216,'English','Steve Krug','New Riders Press','0321344758','978-0321344755');
|
||||
INSERT INTO book VALUES ('The Shallows: What the Internet Is Doing to Our Brains','paperback',276,'English','Nicholas Carr','W. W. Norton & Company ','0393072223','978-0393072228');
|
||||
INSERT INTO book VALUES ('CompTIA A+ Certification All-in-One Exam Guide, Seventh Edition (Exams 220-701 & 220-702)','paperback',1376,'English','Michael Meyers','McGraw-Hill Osborne Media','0071701338','978-0071701334');
|
||||
INSERT INTO book VALUES ('Statistics for People Who (Think They) Hate Statistics: Excel 2007 Edition','paperback',424,'English',NULL,'Sage Publications, Inc','1412971020','978-1412971027');
|
||||
INSERT INTO book VALUES ('Windows 7 For Dummies Book + DVD Bundle','paperback',408,'English','Andy Rathbone','For Dummies','0470523980','978-0470523988');
|
||||
INSERT INTO book VALUES ('Introduction to Algorithms, Third Edition','paperback',1312,'English','Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein','The MIT Press','0262033844','978-0262033848');
|
||||
INSERT INTO book VALUES ('Algorithm Design','paperback',864,'English','Jon Kleinberg, Eva Tardos','Addison Wesley','0321295358','978-0321295354');
|
||||
INSERT INTO book VALUES ('Data Structures and Algorithm Analysis in C++ (3rd Edition)','paperback',586,'English','Mark A. Weiss','Addison Wesley','032144146X','978-0321441461');
|
||||
INSERT INTO book VALUES ('The Algorithm Design Manual','paperback',736,'English','Steven S. Skiena','Springer','1848000693','978-1848000698');
|
||||
INSERT INTO book VALUES ('Introduction to Computing Systems: From bits & gates to C & beyond','paperback',656,'English','Yale Patt, Sanjay Patel','McGraw-Hill Science/Engineering/Math','0072467509','978-0072467505');
|
||||
INSERT INTO book VALUES ('Hackers & Painters: Big Ideas from the Computer Age','paperback',272,'English','Paul Graham','O Reilly Media','1449389554','978-1449389550');
|
||||
INSERT INTO book VALUES ('Data Structures and Algorithms in Java','paperback',736,'English','Michael T. Goodrich, Roberto Tamassia','Wiley','0470383267','978-0470383261');
|
||||
INSERT INTO book VALUES ('Programming Collective Intelligence: Building Smart Web 2.0 Applications','paperback',368,'English','Toby Segaran','O Reilly Media','0596529325','978-0596529321');
|
||||
INSERT INTO book VALUES ('Algorithms of the Intelligent Web','paperback',368,'English','Haralambos Marmanis, Dmitry Babenko','Manning Publications','1933988665','978-1933988665');
|
||||
INSERT INTO book VALUES ('Data Structures and Algorithm Analysis in Java (2nd Edition)','paperback',576,'English','Mark A. Weiss','Addison Wesley','0321370139','978-0321370136');
|
||||
INSERT INTO book VALUES ('Introduction to the Design and Analysis of Algorithms (2nd Edition)','paperback',592,'English','Anany V. Levitin','Addison Wesley','0321358287','978-0321358288');
|
||||
INSERT INTO book VALUES ('Algorithms in a Nutshell (In a Nutshell (O Reilly))','paperback',368,'English','George T. Heineman, Gary Pollice, Stanley Selkow','O Reilly Media','059651624X','978-0596516246');
|
||||
INSERT INTO book VALUES ('Data Analysis with Open Source Tools','paperback',536,'English','Philipp K. Janert','O Reilly Media','0596802358','978-0596802356');
|
||||
INSERT INTO book VALUES ('PHP and MySQL Web Development (4th Edition)','paperback',1008,'English','Luke Welling, Laura Thomson','Addison-Wesley Professional','0672329166','978-0672329166');
|
||||
INSERT INTO book VALUES ('Sams Teach Yourself SQL in 10 Minutes (3rd Edition)','paperback',256,'English','Ben Forta','Sams','0672325675','978-0672325670');
|
||||
INSERT INTO book VALUES ('Database Systems: Design, Implementation, and Management (with Bind-In Printed Access Card)','paperback',700,'English','Carlos Coronel, Steven Morris, Peter Rob','Course Technology','0538469684','978-0538469685');
|
||||
INSERT INTO book VALUES ('New Perspectives on Microsoft Office Access 2007, Comprehensive','paperback',816,'English','Joseph J. Adamski, Kathy T. Finnegan','Course Technology','142390589X','978-1423905899');
|
||||
INSERT INTO book VALUES ('Fundamentals of Database Systems (6th Edition) (Alternative eText Formats)','paperback',1200,'English','Ramez Elmasri, Shamkant Navathe','Addison Wesley','0136086209','978-0136086208');
|
||||
INSERT INTO book VALUES ('New Perspectives on Microsoft Office Access 2007, Brief (New Perspectives Series)','paperback',248,'English','Joseph J. Adamski, Kathy T. Finnegan','Course Technology','1423905873','978-1423905875');
|
||||
INSERT INTO book VALUES ('Concepts of Database Management (Sam 2007 Compatible Products)','paperback',386,'English','Philip J. Pratt, Joseph J. Adamski','Course Technology','1423901479','978-1423901471');
|
||||
INSERT INTO book VALUES ('Microsoft Office Access 2007: Comprehensive Concepts and Techniques (Shelly Cashman)','paperback',792,'English','Gary B. Shelly, Thomas J. Cashman, Philip J. Pratt, Mary Z. Last','Course Technology','1418843415','978-1418843410');
|
||||
INSERT INTO book VALUES ('Database Management Systems','paperback',1104,'English','Raghu Ramakrishnan, Johannes Gehrke','McGraw-Hill Science/Engineering/Math','0072465638','978-0072465631');
|
||||
INSERT INTO book VALUES ('Hadoop: The Definitive Guide','paperback',624,'English','Tom White','Yahoo Press','1449389732','978-1449389734');
|
||||
INSERT INTO book VALUES ('Fundamentals of Information Systems','paperback',488,'English','Ralph Stair, George Reynolds','Course Technology','1423925815','978-1423925811');
|
||||
INSERT INTO book VALUES ('Computer Organization and Design, Fourth Edition: The Hardware/Software Interface (The Morgan Kaufmann Series in Computer Architecture and Design)','paperback',912,'English','David A. Patterson, John L. Hennessy','Morgan Kaufmann','0123744938','978-0123744937');
|
||||
INSERT INTO book VALUES ('Computer Networking: A Top-Down Approach (5th Edition)','paperback',864,'English','James F. Kurose, Keith W. Ross','Addison Wesley','0136079679','978-0136079675');
|
||||
INSERT INTO book VALUES ('CISSP All-in-One Exam Guide, Fifth Edition','paperback',1216,'English','Shon Harris','McGraw-Hill Osborne Media','0071602178','978-0071602174');
|
||||
INSERT INTO book VALUES ('Network+ Guide to Networks (Networking (Course Technology))','paperback',1024,'English','Tamara Dean','Course Technology','1423902459','978-1423902454');
|
||||
INSERT INTO book VALUES ('CCNA Official Exam Certification Library (Exam 640-802), Third Edition (Containing ICND1 and ICND2 Second Edition Exam Certification Guides)','paperback',1475,'English','Wendell Odom','Cisco Press','1587201836','978-1587201837');
|
||||
INSERT INTO book VALUES ('Security+ Guide to Network Security Fundamentals','paperback',640,'English','Mark Ciampa','Course Technology','1428340661','978-1428340664');
|
||||
INSERT INTO book VALUES ('Network Fundamentals, CCNA Exploration Companion Guide','paperback',560,'English','Mark Dye, Rick McDonald, Antoon Rufi','Cisco Press ','1587132087','978-1587132087');
|
||||
INSERT INTO book VALUES ('Guide to Computer Forensics and Investigations','paperback',720,'English','Bill Nelson, Amelia Phillips, Christopher Steuart','Course Technology','1435498836','978-1435498839');
|
||||
INSERT INTO book VALUES ('Principles of Information Security','paperback',550,'English','Michael E. Whitman, Herbert J. Mattord','Course Technology','1423901770','978-1423901778');
|
||||
INSERT INTO book VALUES ('Building Wireless Sensor Networks: with ZigBee, XBee, Arduino, and Processing','paperback',320,'English','Robert Faludi','O Reilly Media','0596807732','978-0596807733');
|
||||
INSERT INTO book VALUES ('CCNA: Cisco Certified Network Associate Study Guide: Exam 640-802','paperback',1008,'English','Todd Lammle','Sybex','0470110082','978-0470110089');
|
||||
INSERT INTO book VALUES ('MCTS Self-Paced Training Kit (Exam 70-680): Configuring Windows 7','paperback',912,'English','Ian McLean, Orin Thomas','Microsoft Press','0735627088','978-0735627086');
|
||||
INSERT INTO book VALUES ('Operating System Concepts','paperback',992,'English','Abraham Silberschatz, Peter B. Galvin, Greg Gagne','Wiley','0470128720','978-0470128725');
|
||||
INSERT INTO book VALUES ('Windows 7 Inside Out','paperback',1056,'English','Ed Bott, Carl Siechert, Craig Stinson','Microsoft Press','0735626650','978-0735626652');
|
||||
INSERT INTO book VALUES ('SPSS Survival Manual: A Step by Step Guide to Data Analysis Using SPSS for Windows (Version 15)',NULL,NULL,'English','Julie Pallant','Open University Press','0335223664','978-0335223664');
|
||||
INSERT INTO book VALUES ('UNIX and Linux System Administration Handbook (4th Edition)','paperback',1344,'English','Evi Nemeth, Garth Snyder, Trent R. Hein, Ben Whaley','Prentice Hall','0131480057','978-0131480056');
|
||||
INSERT INTO book VALUES ('Using SPSS for Windows and Macintosh: Analyzing and Understanding Data (6th Edition)','paperback',480,'English','Samuel B. Green, Neil J. Salkind','Prentice Hall','0205020402','978-0205020409');
|
||||
INSERT INTO book VALUES ('Windows 7 Plain & Simple','paperback',400,'English','Jerry Joyce, Marianne Moon','Microsoft Press','0735626669','978-0735626669');
|
||||
INSERT INTO book VALUES ('Professional SharePoint 2010 Administration','paperback',840,'English','Todd Klindt, Shane Young, Steve Caravajal','Wrox ','0470533331','978-0470533338');
|
||||
INSERT INTO book VALUES ('Practical Guide to Linux Commands, Editors, and Shell Programming, A (2nd Edition)','paperback',1080,'English','Mark G. Sobell','Prentice Hall','0131367366','978-0131367364');
|
||||
INSERT INTO book VALUES ('iPhone and iPad Apps for Absolute Beginners (Getting Started)','paperback',336,'English','Rory Lewis','Apress','1430227001','978-1430227007');
|
||||
INSERT INTO book VALUES ('JavaScript: The Good Parts','paperback',176,'English','Douglas Crockford','Yahoo Press','0596517742','978-0596517748');
|
||||
INSERT INTO book VALUES ('Design Patterns CD: Elements of Reusable Object-Oriented Software (Professional Computing)',NULL,NULL,'English','Erich Gamma, Richard Helm, Ralph Johnson, John M. Vlissides','Addison-Wesley Professional','0201634988','978-0201634983');
|
||||
INSERT INTO book VALUES ('Learning Python, 3rd Edition','paperback',752,'English','Mark Lutz','O Reilly Media','0596513984','978-0596513986');
|
||||
INSERT INTO book VALUES ('Code Complete: A Practical Handbook of Software Construction','paperback',960,'English','Steve McConnell','Microsoft Press','0735619670','978-0735619678');
|
||||
INSERT INTO book VALUES ('The Mythical Man-Month: Essays on Software Engineering, Anniversary Edition (2nd Edition)','paperback',336,'English','Frederick P. Brooks','Addison-Wesley Professional','0201835959','978-0201835953');
|
||||
INSERT INTO book VALUES ('Head First Design Patterns','paperback',688,'English','Elisabeth Freeman, Eric Freeman, Bert Bates, Kathy Sierra','O Reilly Media','0596007124','978-0596007126');
|
||||
INSERT INTO book VALUES ('JavaScript: The Definitive Guide','paperback',1032,'English','David Flanagan','O Reilly Media','0596101996','978-0596101992');
|
||||
INSERT INTO book VALUES ('Clean Code: A Handbook of Agile Software Craftsmanship','paperback',464,'English',NULL,'Prentice Hall','0132350882','978-0132350884');
|
||||
INSERT INTO book VALUES ('Professional Android 2 Application Development (Wrox Programmer to Programmer)','paperback',576,'English','Reto Meier','Wrox','0470565527','978-0470565520');
|
||||
INSERT INTO book VALUES ('Succeeding with Agile: Software Development Using Scrum','paperback',504,'English','Mike Cohn','Addison-Wesley Professional','0321579364','978-0321579362');
|
||||
|
||||
/***************************
|
||||
|
||||
Engineering
|
||||
|
||||
***************************/
|
||||
|
||||
INSERT INTO book VALUES ('Quantitative Chemical Analysis','paperback',928,'English','Daniel C. Harris','W. H. Freeman','0716744643','978-0716744641');
|
||||
INSERT INTO book VALUES ('Transport Phenomena, Revised 2nd Edition','paperback',905,'English','R. Byron Bird, Warren E. Stewart, Edwin N. Lightfoot','John Wiley & Sons, Inc.','0470115394','978-0470115398');
|
||||
INSERT INTO book VALUES ('Introduction to Chemical Engineering Thermodynamics (The Mcgraw-Hill Chemical Engineering Series)','paperback',840,'English','J.M. Smith, Hendrick Van Ness, Michael Abbott','McGraw-Hill Science/Engineering/Math','0073104450','978-0073104454');
|
||||
INSERT INTO book VALUES ('Fundamentals of Momentum, Heat and Mass Transfer','paperback',740,'English','James Welty, Charles E. Wicks, Gregory L. Rorrer, Robert E. Wilson','Wiley','0470128682','978-0470128688');
|
||||
INSERT INTO book VALUES ('Elements of Chemical Reaction Engineering (4th Edition)','paperback',1080,'English','H. Scott Fogler','Prentice Hall','0130473944','978-0130473943');
|
||||
INSERT INTO book VALUES ('Basic Biomechanics','paperback',576,'English','Susan Hall','McGraw-Hill Humanities/Social Sciences/Languages','0073044814','978-0073044811');
|
||||
INSERT INTO book VALUES ('Process Dynamics and Control','paperback',514,'English','Dale E. Seborg, Duncan A. Mellichamp, Thomas F. Edgar, Francis J. Doyle III','Wiley','0470128674','978-0470128671');
|
||||
INSERT INTO book VALUES ('Elementary Principles of Chemical Processes, 3rd Edition 2005 Edition Integrated Media and Study Tools, with Student Workbook',NULL,NULL,'English','Richard M. Felder, Ronald W. Rousseau','Wiley','0471720631','978-0471720638');
|
||||
INSERT INTO book VALUES ('Fluid Mechanics with Student Resources DVD','paperback',992,'English','Yunus Cengel, John Cimbala','McGraw-Hill Science/Engineering/Math','0077295463','978-0077295462');
|
||||
INSERT INTO book VALUES ('Introduction to Environmental Engineering','paperback',1024,'English','Mackenzie Davis, David Cornwell','McGraw-Hill Science/Engineering/Math','0072424117','978-0072424119');
|
||||
INSERT INTO book VALUES ('Separation Process Engineering (2nd Edition)','paperback',704,'English','Phillip C. Wankat','Prentice Hall','0130847895','978-0130847898');
|
||||
INSERT INTO book VALUES ('Mechanics of Materials','paperback',816,'English','Ferdinand Beer, Jr., E. Russell Johnston, John DeWolf, David Mazurek','McGraw-Hill Science/Engineering/Math','0077221400','978-0077221409');
|
||||
INSERT INTO book VALUES ('Civil Engineering Reference Manual for the PE Exam','paperback',1456,'English','Michael R. Lindeburg PE','Professional Publications, Inc.','1591261295','978-1591261292');
|
||||
INSERT INTO book VALUES ('Design of Reinforced Concrete','paperback',720,'English','Jack C. McCormac, Russell Brown','Wiley','0470279273','978-0470279274');
|
||||
INSERT INTO book VALUES ('Principles of Highway Engineering and Traffic Analysis','paperback',420,'English','Fred L. Mannering, Scott S. Washburn, Walter P. Kilareski','Wiley','0470290757','978-0470290750');
|
||||
INSERT INTO book VALUES ('Reinforced Concrete: Mechanics and Design (5th Edition)','paperback',1126,'English','James K. Wight, James G. MacGregor','Prentice Hall','0132281414','978-0132281416');
|
||||
INSERT INTO book VALUES ('Partial Differential Equations for Scientists and Engineers (Dover Books on Advanced Mathematics)','paperback',414,'English','Stanley J. Farlow','Dover Publications ','048667620X','978-0486676203');
|
||||
INSERT INTO book VALUES ('Materials for Civil and Construction Engineers (3rd Edition) (Alternative eText Formats)','paperback',600,'English','Michael S. Mamlouk, John P. Zaniewski','Prentice Hall','0136110584','978-0136110583');
|
||||
INSERT INTO book VALUES ('Principles of Geotechnical Engineering','paperback',704,'English','Braja M. Das','CL-Engineering','0495411302','978-0495411307');
|
||||
INSERT INTO book VALUES ('Experiments With Alternate Currents Of High Potential And High Frequency','paperback',104,'English','Nikola Tesla','Kessinger Publishing, LLC ','1425318754','978-1425318758');
|
||||
INSERT INTO book VALUES ('National Electrical Code 2011 (National Fire Protection Association National Electrical Code)','paperback',870,'English','National Fire Protection Association','Delmar Cengage Learning','0877659141','978-0877659143');
|
||||
INSERT INTO book VALUES ('Electric Circuits','paperback',992,'English','James W. Nilsson, Susan Riedel','Prentice Hall','0131465929','978-0131465923');
|
||||
INSERT INTO book VALUES ('National Electrical Code 2008 (National Fire Protection Association National Electrical Code)','paperback',840,'English','National Fire Protection Association','National Fire Protection Association','0877657904','978-0877657903');
|
||||
INSERT INTO book VALUES ('Electrical Engineering: Principles & Applications ','paperback',896,'English','Allan R. Hambley','Prentice Hall','0131470469','978-0131470460');
|
||||
INSERT INTO book VALUES ('Fundamentals of Electric Circuits with CD-ROM','paperback',960,'English','Charles K. Alexander, Matthew Sadiku','McGraw-Hill Science/Engineering/Math','007249350X','978-0072493504');
|
||||
INSERT INTO book VALUES ('Microelectronic Circuits: includes CD-ROM (The Oxford Series in Electrical and Computer Engineering)','paperback',1392,'English','Adel S. Sedra, Kenneth C. Smith','Oxford University Press, USA','0195142519','978-0195142518');
|
||||
INSERT INTO book VALUES ('Feedback Control of Dynamic Systems','paperback',840,'English','Gene F. Franklin, J. David Powell, Abbas Emami-Naeini','Prentice Hall','0136019692','978-0136019695');
|
||||
INSERT INTO book VALUES ('Fundamentals of Applied Electromagnetics','paperback',528,'English','Fawwaz T. Ulaby, Eric Michielssen, Umberto Ravaioli','Prentice Hall','0132139316','978-0132139311');
|
||||
INSERT INTO book VALUES ('The Analysis and Design of Linear Circuits','paperback',848,'English','Roland E. Thomas, Albert J. Rosa','Wiley','0471272132','978-0471272137');
|
||||
INSERT INTO book VALUES ('Basic Engineering Circuit Analysis','paperback',816,'English','J. David Irwin, R. Mark Nelms','John Wiley & Sons','0471487287','978-0471487289');
|
||||
INSERT INTO book VALUES ('Color Coded EZ Tabs for the 2011 National Electrical Code',NULL,NULL,'English','John Riley','Delmar Cengage Learning','111153697X','978-1111536978');
|
||||
INSERT INTO book VALUES ('Mechanics of Materials','paperback',627,'English','Anthony M. Bedford, Kenneth M. Liechti','Prentice Hall ','0201895528','978-0201895520');
|
||||
INSERT INTO book VALUES ('Fundamentals of Solar Energy Conversion (Addison-Wesley series in mechanics and thermodynamics)','paperback',636,'English','Elmer E. Anderson','Addison Wesley Longman Publishing Co ','0201000083','978-0201000085');
|
||||
INSERT INTO book VALUES ('Fundamentals of Heat and Mass Transfer','paperback',1024,'English','Frank P. Incropera, David P. DeWitt, Theodore L. Bergman, Adrienne S. Lavine','Wiley','0471457280','978-0471457282');
|
||||
INSERT INTO book VALUES ('Engineering Mechanics: Dynamics (12th Edition)','paperback',752,'English','Russell C. Hibbeler','Prentice Hall','0136077919','978-0136077916');
|
||||
INSERT INTO book VALUES ('Shigley s Mechanical Engineering Design (Mcgraw-Hill Series in Mechanical Engineering)','paperback',1104,'English','Richard Budynas, Keith Nisbett','McGraw-Hill Science/Engineering/Math','0073529281','978-0073529288');
|
||||
INSERT INTO book VALUES ('Mechanics of Materials','paperback',790,'English','Ferdinand P. Beer, E. Russell Johnston, John T. Dewolf, David F. Mazurek','McGraw-Hill Higher Education','0073529389','978-0073529387');
|
||||
INSERT INTO book VALUES ('Thermodynamics: An Engineering Approach with Student Resources DVD','paperback',1024,'English','Yunus Cengel, Michael Boles','McGraw-Hill Science/Engineering/Math','0077366743','978-0077366742');
|
||||
INSERT INTO book VALUES ('Statics Study Pack for Engineering Mechanics','paperback',168,'English','Russell C. Hibbeler','Prentice Hall','0136091830','978-0136091837');
|
||||
INSERT INTO book VALUES ('Theory and Design for Mechanical Measurements','paperback',590,'English','Richard S. Figliola, Donald E. Beasley','Wiley','0470547413','978-0470547410');
|
||||
INSERT INTO book VALUES ('Transport Phenomena','paperback',912,'English','R. Byron Bird, Warren E. Stewart, Edwin N. Lightfoot','Wiley','0471410772','978-0471410775');
|
||||
INSERT INTO book VALUES ('Five Hundred and Seven Mechanical Movements: Embracing All Those Which Are Most Important in Dynamics, Hydraulics, Hydrostatics, Pneumatics, Steam Engines...','paperback',122,'English','Henry T. Brown','Astragal Press ','1879335638','978-1879335639');
|
||||
INSERT INTO book VALUES ('Numerical Methods for Engineers, Sixth Edition','paperback',960,'English','Steven Chapra, Raymond Canale','McGraw-Hill Science/Engineering/Math','0073401064','978-0073401065');
|
||||
INSERT INTO book VALUES ('Introduction to Nuclear Engineering (3rd Edition)','paperback',783,'English','John R. Lamarsh, Anthony J. Baratta','Prentice Hall','0201824981','978-0201824988');
|
||||
INSERT INTO book VALUES ('Fundamentals of Nuclear Science and Engineering','paperback',520,'English','J. Kenneth Shultis, Richard E. Faw','CRC Press','0824708342','978-0824708344');
|
||||
INSERT INTO book VALUES ('Nuclear Systems Volume I: Thermal Hydraulic Fundamentals, Second edition','paperback',736,'English','Neil E. Todreas, Mujid Kazimi','Taylor & Francis','1439808872','978-1439808870');
|
||||
INSERT INTO book VALUES ('Nuclear Reactor Analysis','paperback',650,'English','James J. Duderstadt, Louis J. Hamilton','Wiley','0471223638','978-0471223634');
|
||||
INSERT INTO book VALUES ('Nuclear Energy in the 21st Century: World Nuclear University Press','paperback',168,'English','Ian Hore-Lacy','Academic Press','0123736226','978-0123736222');
|
||||
INSERT INTO book VALUES ('Nuclear Energy: Principles, Practices, and Prospects','paperback',693,'English','David Bodansky','Springer','0387207783','978-0387207780');
|
||||
INSERT INTO book VALUES ('The Tainted Desert: Environmental and Social Ruin in the American West','paperback',368,'English','Valerie L. Kuletz','Routledge','0415917719','978-0415917711');
|
||||
INSERT INTO book VALUES ('Introduction to Nuclear And Particle Physics: Solutions Manual for Second Edition of Text by Das and Ferbel','paperback',180,'English','C. Bromberg, A Das, T Ferbel','World Scientific Publishing Company','9812567445','978-9812567444');
|
||||
INSERT INTO book VALUES ('Fundamentals of Radiation Materials Science: Metals and Alloys','paperback',827,'English','Gary S. Was','Springer','3540494715','978-3540494713');
|
||||
INSERT INTO book VALUES ('Fire from Ice: Searching for the Truth Behind the Cold Fusion Furor (Wiley Science Editions)','paperback',352,'English','Eugene J. Mallove','John Wiley & Sons Inc','0471531391','978-0471531395');
|
||||
INSERT INTO book VALUES ('Radiation Protection and Dosimetry: An Introduction to Health Physics','paperback',384,'English','Michael G. Stabin','Springer','0387499822','978-0387499826');
|
||||
INSERT INTO book VALUES ('Information Technology Project Management','paperback',512,'English','Kathy Schwalbe','Course Technology','076001180X','978-0760011805');
|
||||
INSERT INTO book VALUES ('Project Management: A Systems Approach to Planning, Scheduling, and Controlling','paperback',1120,'English','Harold Kerzner','Wiley','0470278706','978-0470278703');
|
||||
INSERT INTO book VALUES ('Design and Analysis of Experiments: MINITAB Companion','paperback',114,'English','Douglas C. Montgomery, Scott M. Kowalski','Wiley','0470169907','978-0470169902');
|
||||
INSERT INTO book VALUES ('Microsoft Office Project 2007 Step by Step (Step By Step (Microsoft))','paperback',560,'English','Carl Chatfield, Timothy Johnson D.','Microsoft Press ','0735623058','978-0735623057');
|
||||
INSERT INTO book VALUES ('Applied Numerical Methods with MATLAB for Engineers and Scientists','paperback',400,'English','Steven C. Chapra','McGraw-Hill Science/Engineering/Math','0072392657','978-0072392654');
|
||||
INSERT INTO book VALUES ('Principles of Highway Engineering and Traffic Analysis','paperback',272,'English','Fred L. Mannering, Walter P. Kilareski','John Wiley & Sons Inc ','0471635324','978-0471635321');
|
||||
INSERT INTO book VALUES ('Applied Statistics and Probability for Engineers','paperback',784,'English','Douglas C. Montgomery, George C. Runger','Wiley','0470053046','978-0470053041');
|
||||
INSERT INTO book VALUES ('Fundamentals of Modern Manufacturing: Materials, Processes, and Systems','paperback',1024,'English','Mikell P. Groover','Wiley','0470467002','978-0470467008');
|
||||
INSERT INTO book VALUES ('Product Design and Development','paperback',384,'English','Karl Ulrich, Steven Eppinger','McGraw-Hill/Irwin','0072471468','978-0072471465');
|
||||
INSERT INTO book VALUES ('Engineering Economic Analysis','paperback',624,'English','Donald G. Newnan, Ted G. Eschenbach, Jerome P. Lavelle','Oxford University Press, USA','0195168070','978-0195168075');
|
||||
INSERT INTO book VALUES ('Statistics for Engineers and Scientists','paperback',928,'English','William Navidi','McGraw-Hill Science/Engineering/Math','0073376337','978-0073376332');
|
||||
INSERT INTO book VALUES ('Introduction to Statistical Quality Control','paperback',734,'English','Douglas C. Montgomery','Wiley','0470169923','978-0470169926');
|
||||
|
||||
/***************************
|
||||
|
||||
Arts & social science (history)
|
||||
|
||||
***************************/
|
||||
|
||||
|
||||
INSERT INTO book VALUES ('Dracula','paperback',368,'English','Bram Stoker','Nabu Press ','1177759144','978-1177759144');
|
||||
INSERT INTO book VALUES ('The Autobiography of Benjamin Franklin','paperback',146,'English','Benjamin Franklin','IndoEuropeanPublishing.com ','1604443413','978-1604443417');
|
||||
INSERT INTO book VALUES ('Common Sense (Penguin Classics)','paperback',128,'English','Thomas Paine','Penguin Classics ','0140390162','978-0140390162');
|
||||
INSERT INTO book VALUES ('Persuasion','paperback',390,'English','Jane Austen','Nabu Press ','1178018636','978-1178018639');
|
||||
INSERT INTO book VALUES ('The Big Short: Inside the Doomsday Machine (Thorndike Press Large Print Nonfiction Series)','paperback',411,'English','Michael Lewis','Thorndike Press','141043026X','978-1410430267');
|
||||
INSERT INTO book VALUES ('The Memorable Thoughts of Socrates','paperback',140,'English','Xenophon','Watchmaker Publishing ','1603863206','978-1603863209');
|
||||
INSERT INTO book VALUES ('Japanese fairy tales','paperback',332,'English','Yei Theodora Ozaki','Nabu Press ','1176742620','978-1176742628');
|
||||
INSERT INTO book VALUES ('The Swiss Family Robinson: or, Adventures in a desert island','paperback',200,'English','Johann David Wyss','Nabu Press ','1172290059','978-1172290055');
|
||||
INSERT INTO book VALUES ('Thus Spake Zarathustra','paperback',320,'English','Friedrich Nietzsche','Kessinger Publishing, LLC ','1169319890','978-1169319899');
|
||||
INSERT INTO book VALUES ('The Pilgrim s Progress From This World to That Which Is to Come, Delivered Under the Similitude of a Dream, by John Bunyan','paperback',100,'English','John Bunyan','General Books LLC ','1153716577','978-1153716574');
|
||||
INSERT INTO book VALUES ('Dubliners','paperback',286,'English','James Joyce','Nabu Press ','117776153X','978-1177761536');
|
||||
INSERT INTO book VALUES ('Sidelights on relativity','paperback',80,'English','Albert Einstein, G B. 1891- Jeffery, W Perrett','Nabu Press ','1176977113','978-1176977112');
|
||||
INSERT INTO book VALUES ('India: An Illustrated History (Hippocrene Illustrated Histories)','paperback',200,'English','Prem Kishore, Anuradha Kishore Ganpati','Hippocrene Books','0781809444','978-0781809443');
|
||||
INSERT INTO book VALUES ('Indian Heroes and Great Chieftains (Large Print)','paperback',224,'English','Charles A. Eastman','Tutis Digital Publishing Pvt. Ltd. ','8184566913','978-8184566918');
|
||||
INSERT INTO book VALUES ('Sun Tzu s The Art of War','paperback',72,'English','Sun Tzu','Prohyptikon Publishing Inc. ','0981224407','978-0981224404');
|
||||
INSERT INTO book VALUES ('The Bhagavad-Gita','paperback',168,'English',NULL,'Columbia University Press ','0231064683','978-0231064682');
|
||||
INSERT INTO book VALUES ('The Rape of Nanking: The Forgotten Holocaust of World War II','paperback',290,'English','Iris Chang','Penguin ','0140277447','978-0140277449');
|
||||
INSERT INTO book VALUES ('The Problem of China (with footnotes and index)','paperback',176,'English','Bertrand Russell','Arc Manor ','1604500832','978-1604500837');
|
||||
INSERT INTO book VALUES ('Lost to the West: The Forgotten Byzantine Empire That Rescued Western Civilization','paperback',352,'English','Lars Brownworth','Crown','0307407950','978-0307407955');
|
||||
INSERT INTO book VALUES ('The Coldest Winter: America and the Korean War (Thorndike Press Large Print Nonfiction Series)','paperback',1240,'English','David Halberstam','Thorndike Press ','0786298324','978-0786298327');
|
||||
INSERT INTO book VALUES ('The Origins of the Modern World: A Global and Ecological Narrative from the Fifteenth to the Twenty-first Century (World Social Change)','paperback',240,'English','Robert B. Marks','Rowman & Littlefield Publishers, Inc.','0742554198','978-0742554191');
|
||||
INSERT INTO book VALUES ('The Cambridge Illustrated History of China (Cambridge Illustrated Histories)','paperback',384,'English','Patricia Buckley Ebrey','Cambridge University Press','0521124336','978-0521124331');
|
||||
INSERT INTO book VALUES ('Strangers from a Different Shore: A History of Asian Americans, Updated and Revised Edition','paperback',640,'English','Ronald Takaki','Little, Brown and Company','0316831301','978-0316831307');
|
||||
INSERT INTO book VALUES ('Krakatoa: The Day the World Exploded: August 27, 1883','paperback',464,'English','Simon Winchester','Harper Perennial','0060838590','978-0060838591');
|
||||
|
||||
/***************************
|
||||
|
||||
Arts & social science (language)
|
||||
|
||||
***************************/
|
||||
|
||||
INSERT INTO book VALUES ('Thus Spoke Zarathustra (Selections) / Also sprach Zarathustra (Auswahl): A Dual-Language Book (Dual-Language Books)','paperback',240,'English','Friedrich Nietzsche','Dover Publications','0486437116','978-0486437118');
|
||||
INSERT INTO book VALUES ('Do Androids Dream of Electric Sheep?: 1800 Headwords (Oxford Bookworms Library)','paperback',128,'English','Philip K. Dick','Oxford University Press ','0194792226','978-0194792226');
|
||||
INSERT INTO book VALUES ('A Is for Alibi (Kinsey Milhone Mysteries)','paperback',307,'English','Sue Grafton','St. Martin s Griffin','1405072873','978-1405072878');
|
||||
INSERT INTO book VALUES ('1001 Most Useful Spanish Words (Beginners Guides)','paperback',64,'English','Seymour Resnick','Dover Publications','0486291138','978-0486291130');
|
||||
INSERT INTO book VALUES ('The Metamorphosis','paperback',82,'English','Franz Kafka','Martino Fine Books ','1578987857','978-1578987856');
|
||||
INSERT INTO book VALUES ('Practice Makes Perfect Spanish Verb Tenses, Second Edition (Practice Makes Perfect Series)','paperback',352,'English','Dorothy Richmond','McGraw-Hill','0071639306','978-0071639309');
|
||||
INSERT INTO book VALUES ('Aproximaciones al estudio de la literatura hispanica, sexta edicion (Spanish Edition)','paperback',468,'Spanish','Carmelo Virgillo, Edward Friedman, Teresa Valdivieso','McGraw-Hill Humanities/Social Sciences/Languages','0073513156','978-0073513157');
|
||||
INSERT INTO book VALUES ('Sun Tzu on the Art of War: The Oldest Military Treatise in the World (Sunzi for Language Learners, Volume 1) (Mandarin Chinese Edition)','paperback',272,'Mandarin Chinese','Sun Tzu, Sunzi','Hanyu Press ','0973892420','978-0973892420');
|
||||
INSERT INTO book VALUES ('Understanding and Using English Grammar (with Answer Key and Audio CDs) (4th Edition)','paperback',530,'English','Betty Schrampfer Azar, Stacy A. Hagen','Pearson Longman','0132333317','978-0132333313');
|
||||
INSERT INTO book VALUES ('Puntos de partida: An Invitation to Spanish (Student Edition)','paperback',688,'English','Marty Knorre, Thalia Dorwick, Ana Maria Perez Girones, William R. Glass, Hildebrando Villarreal','McGraw-Hill Humanities/Social Sciences/Languages','0073534420','978-0073534428');
|
||||
INSERT INTO book VALUES ('Reading, Writing and Learning in ESL: A Resource Book for K-12 Teachers ','paperback',464,'English','Suzanne F. Peregoy, Owen F. Boyle','Allyn & Bacon','0205410340','978-0205410347');
|
||||
INSERT INTO book VALUES ('501 Spanish Verbs with CD-ROM and Audio CD (501 Verb Series)','paperback',736,'English','Christopher Kendris, Theodore Kendris','Barron s Educational Series','0764197975','978-0764197970');
|
||||
INSERT INTO book VALUES ('Integrated Chinese: Textbook Simplified Characters, Level 1, Part 2 Simplified Text (Chinese Edition)','paperback',403,'Chinese','Yuehua Liu, Daozhong Yao','Cheng & Tsui','0887276709','978-0887276705');
|
||||
INSERT INTO book VALUES ('Integrated Chinese, Level 1 Part 1 Textbook, 3rd Edition (Traditional)','paperback',368,'English','Yuehua Liu','Cheng & Tsui','0887276393','978-0887276392');
|
||||
INSERT INTO book VALUES ('Integrated Chinese, Level 1, Part 2: Workbook (Traditional Character Edition) (Level 1 Traditional Character Texts)',NULL,NULL,'English','Yuehua Liu, Tao-Chung Yao','Cheng & Tsui','0887272703','978-0887272707');
|
||||
INSERT INTO book VALUES ('Tuttle Learning Chinese Characters: A Revolutionary New Way to Learn and Remember the 800 Most Basic Chinese Characters','paperback',384,'English','Alison Matthews, Laurence Matthews','Tuttle Publishing ','080483816X','978-0804838160');
|
||||
INSERT INTO book VALUES ('Schaum s Outline of Chinese Grammar (Schaum s Outline Series)','paperback',288,'English','Claudia Ross','McGraw-Hill','0071635262','978-0071635264');
|
||||
INSERT INTO book VALUES ('Integrated Chinese: Level 2, Part 1 (Simplified and Traditional Character) Textbook (Chinese Edition)','paperback',464,'Chinese','Yuehua Liu, Tao-chung Yao, Yaohua Shi, Nyan-Ping Bi, Liangyan Ge','Cheng & Tsui','0887276806','978-0887276804');
|
||||
INSERT INTO book VALUES ('Integrated Chinese, Level 2 Part 2 Textbook (The Integrated Chinese Series) (Chinese Edition)','paperback',447,'Chinese','Yuehua Liu, Tao-chung Yao, Nyan-Ping Bi, Liangyan Ge, Yaohua Shi','Cheng & Tsui','088727689X','978-0887276897');
|
||||
INSERT INTO book VALUES ('Oxford Beginner s Chinese Dictionary','paperback',512,'English',NULL,'Oxford University Press, USA','019929853X','978-0199298532');
|
||||
INSERT INTO book VALUES ('Integrated Chinese: Level 2, Part 1 (Simplified and Traditional Character) Workbook (Chinese Edition)','paperback',216,'Chinese','Yuehua Liu, Tao-chung Yao, Liangyan Ge, Nyan-Ping Bi, Yaohua Shi','Cheng & Tsui','0887276830','978-0887276835');
|
||||
INSERT INTO book VALUES ('Integrated Chinese: Level 1, Part 1 Simplified Character Edition (Textbook)','paperback',354,'English','Tao-chung Yao, Yuehua Liu, Liangyan Ge, Yea-fen Chen, Nyan-Ping Bi','Cheng & Tsui','0887275338','978-0887275333');
|
||||
INSERT INTO book VALUES ('Integrated Chinese: Level 2 Part 2 Workbook (Chinese Edition)','paperback',190,'Chinese','Yuehua Liu, Tao-chung Yao, Nyan-Ping Bi, Liangyan Ge, Yaohua Shi','Cheng & Tsui','088727692X','978-0887276927');
|
||||
|
||||
|
||||
/***************************
|
||||
|
||||
Arts & social science (geography)
|
||||
|
||||
***************************/
|
||||
|
||||
INSERT INTO book VALUES ('Guns, Germs, and Steel: The Fates of Human Societies','paperback',496,'English','Jared M. Diamond','W. W. Norton & Company','0393317552','978-0393317558');
|
||||
INSERT INTO book VALUES ('The Cultural Landscape: An Introduction to Human Geography (10th Edition)','paperback',528,'English','James M. Rubenstein','Prentice Hall','0321677358','978-0321677358');
|
||||
INSERT INTO book VALUES ('Globalization and Diversity: Geography of a Changing World (3rd Edition)','paperback',480,'English','Lester Rowntree, Martin Lewis, Marie Price, William Wyckoff','Prentice Hall','0321651529','978-0321651525');
|
||||
INSERT INTO book VALUES ('The Human Mosaic','paperback',496,'English','Mona Domosh, Roderick P. Neumann, Patricia L. Price, Terry G. Jordan-Bychkov','W. H. Freeman','1429214260','978-1429214261');
|
||||
INSERT INTO book VALUES ('The Cultural Landscape: An Introduction to Human Geography (9th Edition)','paperback',576,'English','James M. Rubenstein','Prentice Hall','013243573X','978-0132435734');
|
||||
INSERT INTO book VALUES ('Places and Regions in Global Context: Human Geography (5th Edition)','paperback',544,'English','Paul L. Knox, Sallie A. Marston','Prentice Hall','0321580028','978-0321580023');
|
||||
INSERT INTO book VALUES ('Pandora s Seed: The Unforeseen Cost of Civilization','paperback',256,'English','Spencer Wells','Random House','1400062152','978-1400062157');
|
||||
INSERT INTO book VALUES ('Human Geography: People, Place, and Culture','paperback',544,'English','Erin H. Fouberg, Alexander B. Murphy, H. J. de Blij','Wiley','0470382589','978-0470382585');
|
||||
INSERT INTO book VALUES ('Contemporary Human Geography','paperback',384,'English','James M. Rubenstein','Prentice Hall','0321590031','978-0321590039');
|
||||
INSERT INTO book VALUES ('Student Atlas of World Geography','paperback',336,'English','John Allen','McGraw-Hill/Dushkin','0073527602','978-0073527604');
|
||||
INSERT INTO book VALUES ('The Control of Nature','paperback',272,'English','John McPhee','Farrar, Straus and Giroux','0374128901','978-0374128906');
|
||||
INSERT INTO book VALUES ('Cities of the World: World Regional Urban Development','paperback',680,'English',NULL,'Rowman & Littlefield Publishers, Inc.','0742555976','978-0742555976');
|
||||
|
||||
|
||||
/***************************
|
||||
|
||||
Arts & social science (economics)
|
||||
|
||||
***************************/
|
||||
|
||||
INSERT INTO book VALUES ('The Communist Manifesto (Norton Critical Editions)','paperback',224,'English','Karl Marx','W. W. Norton & Company','0393956164','978-0393956160');
|
||||
INSERT INTO book VALUES ('The Wealth of Nations (Modern Library Classics)','paperback',1184,'English','Adam Smith, Robert Reich','Modern Library ','0679783369','978-0679783367');
|
||||
INSERT INTO book VALUES ('The Law','paperback',112,'English','Frederic Bastiat','www.bnpublishing.com ','9562913627','978-9562913621');
|
||||
INSERT INTO book VALUES ('The Economic Consequences of the Peace','paperback',138,'English','John Maynard Keynes','General Books LLC ','1770454616','978-1770454613');
|
||||
INSERT INTO book VALUES ('The Wealth of Nations (Bantam Classics)',NULL,NULL,'English','Adam Smith','Bantam Classics ','0553585975','978-0553585971');
|
||||
INSERT INTO book VALUES ('Naked Economics: Undressing the Dismal Science','paperback',260,'English','Charles Wheelan','W. W. Norton & Company ','0393324869','978-0393324860');
|
||||
INSERT INTO book VALUES ('Political Ideals','paperback',112,'English','Bertrand Russell','IndyPublish ','1414282893','978-1414282893');
|
||||
INSERT INTO book VALUES ('Capitalism and Freedom: Fortieth Anniversary Edition','paperback',230,'English','Milton Friedman','University Of Chicago Press','0226264211','978-0226264219');
|
||||
INSERT INTO book VALUES ('On Liberty and Utilitarianism (Everyman s Library (Cloth))',NULL,NULL,'English','John Stuart Mill','Everyman s Library ','0679413294','978-0679413295');
|
||||
INSERT INTO book VALUES ('How an Economy Grows and Why It Crashes','paperback',256,'English','Peter D. Schiff, Andrew J. Schiff','Wiley ','047052670X','978-0470526705');
|
||||
INSERT INTO book VALUES ('When Genius Failed: The Rise and Fall of Long-Term Capital Management','paperback',288,'English','Roger Lowenstein','Random House Trade Paperbacks ','0375758259','978-0375758256');
|
||||
INSERT INTO book VALUES ('The Theory of Moral Sentiments (Penguin Classics)','paperback',528,'English','Adam Smith','Penguin Classics','0143105922','978-0143105923');
|
||||
INSERT INTO book VALUES ('Principles of Macroeconomics','paperback',584,'English','N. Gregory Mankiw','South-Western College Pub','0324589999','978-0324589993');
|
||||
INSERT INTO book VALUES ('Kaplan AP Macroeconomics/Microeconomics 2011','paperback',360,'English','Sangeeta Bishop, Christine Parrott, Chuck Martie, Raymond Miller','Kaplan Publishing ','1607145332','978-1607145332');
|
||||
INSERT INTO book VALUES ('Macroeconomics (McGraw-Hill Economics)','paperback',512,'English','Campbell McConnell, Stanley Brue, Sean Flynn','McGraw-Hill/Irwin','0073365947','978-0073365947');
|
||||
INSERT INTO book VALUES ('Naked Economics: Undressing the Dismal Science','paperback',288,'English','Charles Wheelan','W. W. Norton & Company','0393049825','978-0393049824');
|
||||
INSERT INTO book VALUES ('Macroeconomics','paperback',608,'English','N. Gregory Mankiw','Worth Publishers','1429218878','978-1429218870');
|
||||
INSERT INTO book VALUES ('Macroeconomics & MyEconLab Student Access Code Card (3rd Edition)',NULL,NULL,'English','Glenn Hubbard, Anthony P. O Brien','Prentice Hall','0132479362','978-0132479363');
|
||||
INSERT INTO book VALUES ('Study Guide for Macroeconomics','paperback',504,'English','Paul Krugman, Robin Wells, Elizabeth Kelly','Worth Publishers','1429217553','978-1429217552');
|
||||
INSERT INTO book VALUES ('Animal Spirits: How Human Psychology Drives the Economy, and Why It Matters for Global Capitalism (New in Paper)','paperback',256,'English','George A. Akerlof, Robert J. Shiller','Princeton University Press','069114592X','978-0691145921');
|
||||
INSERT INTO book VALUES ('Brief Principles of Macroeconomics','paperback',468,'English','N. Gregory Mankiw','South-Western College Pub','0324590377','978-0324590371');
|
||||
INSERT INTO book VALUES ('Principles of Macroeconomics (9th Edition)','paperback',472,'English','Karl E. Case, Ray C. Fair, Sharon Oster','Prentice Hall','0136058965','978-0136058960');
|
||||
INSERT INTO book VALUES ('Macroeconomics (3rd Edition)','paperback',720,'English','Glenn Hubbard, Anthony P. O Brien','Prentice Hall','0136021824','978-0136021827');
|
||||
INSERT INTO book VALUES ('Principles of Microeconomics and ActiveEcon CD Package (6th Edition)','paperback',451,'English','Karl E. Case, Ray C. Fair','Pearson Education','0130746436','978-0130746436');
|
||||
|
||||
|
||||
/***************************
|
||||
|
||||
Science (biology)
|
||||
|
||||
***************************/
|
||||
|
||||
|
||||
INSERT INTO book VALUES ('Biology with MasteringBiology (8th Edition)','paperback',1393,'English','Neil A. Campbell, Jane B. Reece','Benjamin Cummings','0321543254','978-0321543257');
|
||||
INSERT INTO book VALUES ('Kaplan MCAT Biology Review','paperback',560,'English','Kaplan','Kaplan Publishing','1607146436','978-1607146438');
|
||||
INSERT INTO book VALUES ('Notes on Nursing: What It Is, and What It Is Not','paperback',140,'English','Florence Nightingale','Dover Publications','048622340X','978-0486223407');
|
||||
INSERT INTO book VALUES ('Kaplan AP Biology 2011','paperback',360,'English','Linda Brooke Stabler, Mark Metz, Paul Gier','Kaplan Publishing ','1607145243','978-1607145240');
|
||||
INSERT INTO book VALUES ('Kaplan GRE Exam Subject Test: Biology 2009-2010 Edition ','paperback',456,'English','Kaplan','Kaplan Publishing','141955218X','978-1419552182');
|
||||
INSERT INTO book VALUES ('Microbiology: An Introduction, Books a la Carte Edition (10th Edition)','paperback',960,'English','Gerard J. Tortora, Berdell R. Funke, Christine L. Case','Benjamin Cummings','0321582039','978-0321582034');
|
||||
INSERT INTO book VALUES ('Kaplan SAT Subject Test: Biology E/M 2009-2010 Edition (Kaplan Sat Subject Test. Biology E/M)','paperback',396,'English','Kaplan','Kaplan Publishing ','1419552597','978-1419552595');
|
||||
INSERT INTO book VALUES ('On the Origin of Species (Penguin Classics)','paperback',480,'English','Charles Darwin','Penguin Classics ','0140439129','978-0140439120');
|
||||
INSERT INTO book VALUES ('Stiff: The Curious Lives of Human Cadavers','paperback',303,'English','Mary Roach','W. W. Norton & Company','0393050939','978-0393050936');
|
||||
INSERT INTO book VALUES ('The Developing Person Through the Life Span (paper)','paperback',667,'English','Kathleen Stassen Berger','Worth Publishers','0716791595','978-0716791591');
|
||||
INSERT INTO book VALUES ('Physiology: Board Review Series','paperback',326,'English','Linda Costanzo','Lippincott Williams & Wilkins','0683303961','978-0683303964');
|
||||
INSERT INTO book VALUES ('Understanding Human Communication','paperback',544,'English','Ronald B. Adler, George Rodman','Oxford University Press, USA','0195219104','978-0195219104');
|
||||
INSERT INTO book VALUES ('Biology of Plants','paperback',944,'English','Peter H. Raven, Ray F. Evert, Susan E. Eichhorn','W. H. Freeman','0716710072','978-0716710073');
|
||||
INSERT INTO book VALUES ('Biological Science: Plant/Animal (Volume 3)','paperback',324,'English','Scott Freeman','Prentice Hall ','0130933155','978-0130933157');
|
||||
INSERT INTO book VALUES ('The New Testament: A Historical Introduction to the Early Christian Writings','paperback',560,'English','Bart D. Ehrman','Oxford University Press, USA','0195154622','978-0195154627');
|
||||
INSERT INTO book VALUES ('Microelectronic Circuits (Holt Rinehart and Winston Series in Electrical Engineering)','paperback',1144,'English','Adel S. Sedra, Kenneth C. Smith','Oxford University Press, USA','019510370X','978-0195103700');
|
||||
INSERT INTO book VALUES ('A Field Guide to Edible Wild Plants: Eastern and central North America (Peterson Field Guide)','paperback',352,'English',NULL,'Houghton Mifflin Harcourt ','039592622X','978-0395926222');
|
||||
INSERT INTO book VALUES ('The Power of Movement in Plants (Classic Reprint)','paperback',616,'English','Charles Darwin','Forgotten Books ','1440079986','978-1440079986');
|
||||
INSERT INTO book VALUES ('Writing History: A Guide for Students','paperback',128,'English','William Kelleher Storey','Oxford University Press, USA','0195166094','978-0195166095');
|
||||
INSERT INTO book VALUES ('Plants and Society','paperback',544,'English','Estelle Levetin, Karen McMahon','McGraw-Hill Science/Engineering/Math','0077221257','978-0077221256');
|
||||
INSERT INTO book VALUES ('Reporting for the Media','paperback',704,'English','Fred Fedler, John R. Bender, Lucinda Davenport, Michael W. Drager','Oxford University Press, USA','0195169999','978-0195169997');
|
||||
INSERT INTO book VALUES ('Plant Physiology, Fifth Edition','paperback',782,'English','Lincoln Taiz, Eduardo Zeiger','Sinauer Associates, Inc.','0878938664','978-0878938667');
|
||||
INSERT INTO book VALUES ('The Modern Middle East: A History','paperback',368,'English','James L. Gelvin','Oxford University Press, USA ','0195167880','978-0195167887');
|
||||
|
||||
/***************************
|
||||
|
||||
Science (chemistry)
|
||||
|
||||
***************************/
|
||||
|
||||
INSERT INTO book VALUES ('Kaplan MCAT General Chemistry Review','paperback',464,'English','Kaplan','Kaplan Publishing','1607146398','978-1607146391');
|
||||
INSERT INTO book VALUES ('Kaplan SAT Subject Test Chemistry 2010-2011 Edition (Kaplan Sat Subject Test. Chemistry)','paperback',396,'English','Claire Aldridge, Karl Lee, Kaplan','Kaplan Publishing','1419553461','978-1419553462');
|
||||
INSERT INTO book VALUES ('Lehninger Principles of Biochemistry & eBook','paperback',1263,'English','Albert Lehninger, David L. Nelson, Michael M. Cox','W. H. Freeman','1429224169','978-1429224161');
|
||||
INSERT INTO book VALUES ('Chemistry: The Central Science (11th Edition)','paperback',1232,'English','Theodore E. Brown, H. Eugene H LeMay, Bruce E. Bursten, Catherine Murphy, Patrick Woodward','Prentice Hall','0136006175','978-0136006176');
|
||||
INSERT INTO book VALUES ('Quantitative Chemical Analysis','paperback',750,'English','Daniel C. Harris','W. H. Freeman','1429218150','978-1429218153');
|
||||
INSERT INTO book VALUES ('Organic Chemistry II as a Second Language: Second Semester Topics','paperback',320,'English','David M. Klein','Wiley','0471738085','978-0471738084');
|
||||
INSERT INTO book VALUES ('Chemistry: An Introduction to General, Organic, & Biological Chemistry (10th Edition)','paperback',744,'English','Karen C. Timberlake','Prentice Hall','0136019706','978-0136019701');
|
||||
INSERT INTO book VALUES ('Introductory Chemistry Essentials (4th Edition)','paperback',736,'English','Nivaldo J. Tro','Prentice Hall','0321725999','978-0321725998');
|
||||
INSERT INTO book VALUES ('Chemistry: The Molecular Nature of Matter and Change','paperback',1232,'English','Martin Silberberg','McGraw-Hill Science/Engineering/Math','0077216504','978-0077216504');
|
||||
INSERT INTO book VALUES ('Study Guide for Chemistry: A Molecular Approach','paperback',352,'English','Nivaldo J. Tro, Jennifer J. Shanoski','Prentice Hall','0321667883','978-0321667885');
|
||||
INSERT INTO book VALUES ('Organic Chemistry I as a Second Language: Translating the Basic Concepts','paperback',336,'English','David M. Klein','Wiley','0470129298','978-0470129296');
|
||||
INSERT INTO book VALUES ('Organic Chemistry I As a Second Language: Translating the Basic Concepts','paperback',363,'English','David R. Klein','John Wiley & Sons','111801040X','978-1118010402');
|
||||
|
||||
/***************************
|
||||
|
||||
Science (mathematics)
|
||||
|
||||
***************************/
|
||||
|
||||
INSERT INTO book VALUES ('Kaplan AP Calculus AB & BC 2011 (Kaplan Ap Calculus Ab and Bc)','paperback',624,'English','Tamara Lefcourt Ruby, James Sellers, Lisa Korf, Jeremy Van Horn, Mike Munn','Kaplan Publishing ','1607145251','978-1607145257');
|
||||
INSERT INTO book VALUES ('Calculus: Early Transcendentals','paperback',1344,'English','James Stewart','Brooks Cole','0538497904','978-0538497909');
|
||||
INSERT INTO book VALUES ('Calculus (Stewart s Calculus Series)','paperback',1344,'English','James Stewart','Brooks Cole','0495011606','978-0495011606');
|
||||
INSERT INTO book VALUES ('Calculus','paperback',1328,'English','Ron Larson, Bruce H. Edwards','Brooks Cole','0547167024','978-0547167022');
|
||||
INSERT INTO book VALUES ('Applied Calculus','paperback',560,'English','Deborah Hughes-Hallett, Patti Frazer Lock, Andrew M. Gleason, Daniel E. Flath, Sheldon P. Gordon, David O. Lomen, David Lovelock, William G. McCallum, Brad G. Osgood, Andrew Pasquale, Jeff Tecosky-Feldman, Joseph Thrash, Karen R. Rhea, Thomas W. Tucker','Wiley','0470170522','978-0470170526');
|
||||
INSERT INTO book VALUES ('Functions Modeling Change: A Preparation for Calculus','paperback',624,'English','Eric Connally','Wiley','0471793035','978-0471793038');
|
||||
INSERT INTO book VALUES ('Essential Calculus: Early Transcendentals','paperback',912,'English','James Stewart','Brooks Cole','0495014281','978-0495014287');
|
||||
INSERT INTO book VALUES ('Beginning and Intermediate Algebra','paperback',1136,'English','Julie Miller','McGraw-Hill Science/Engineering/Math','0072965339','978-0072965339');
|
||||
INSERT INTO book VALUES ('Student Solutions Manual for Blanchard/Devaney/Hall s Differential Equations, 3rd','paperback',336,'English','Paul Blanchard, Robert L. Devaney, Glen R. Hall','Brooks Cole','0495014613','978-0495014614');
|
||||
INSERT INTO book VALUES ('Calculus and Its Applications (10th Edition)','paperback',696,'English','Marvin L. Bittinger, David J. Ellenbogen, Scott Surgent','Addison Wesley','0321694333','978-0321694331');
|
||||
INSERT INTO book VALUES ('Cracking the AP Calculus AB & BC Exams, 2011 Edition (College Test Preparation)','paperback',896,'English','Princeton Review','Princeton Review ','0375429883','978-0375429880');
|
||||
INSERT INTO book VALUES ('Calculus: Single Variable','paperback',736,'English','Deborah Hughes-Hallett, Andrew M. Gleason, William G. McCallum, David O. Lomen, David Lovelock, Jeff Tecosky-Feldman, Thomas W. Tucker, Daniel E. Flath, Joseph Thrash, Karen R. Rhea, Andrew Pasquale, Sheldon P. Gordon, Douglas Quinney, Patti Frazer Lock','Wiley','0470089156','978-0470089156');
|
||||
INSERT INTO book VALUES ('The Shape of Inner Space: String Theory and the Geometry of the Universe s Hidden Dimensions','paperback',400,'English','Shing-Tung Yau, Steve Nadis','Basic Books ','0465020232','978-0465020232');
|
||||
INSERT INTO book VALUES ('The Developing Person Through Childhood and Adolescence & Media Tool Kit','paperback',550,'English','Kathleen Stassen Berger','Worth Publishers','0716704749','978-0716704744');
|
||||
INSERT INTO book VALUES ('Student Study Guide Part 1 for Calculus','paperback',250,'English','George B. Thomas','Addison Wesley','020153181X','978-0201531817');
|
||||
INSERT INTO book VALUES ('The Fractal Geometry of Nature','paperback',468,'English','Benoit B. Mandelbrot','Times Books','0716711869','978-0716711865');
|
||||
INSERT INTO book VALUES ('Schaum s Outline of Calculus, 5th ed. (Schaum s Outline Series)','paperback',552,'English','Frank Ayres, Elliott Mendelson','McGraw-Hill','0071508619','978-0071508612');
|
||||
INSERT INTO book VALUES ('Geometry: Solution Key','paperback',422,'English','Ray C. Jurgensen, Richard G. Brown, John W. Jurgensen','Houghton Mifflin ','0395677661','978-0395677667');
|
||||
INSERT INTO book VALUES ('Introduction to Topology: Third Edition','paperback',224,'English','Bert Mendelson','Dover Publications','0486663523','978-0486663524');
|
||||
INSERT INTO book VALUES ('Calculus, 8th Edition',NULL,NULL,'English','Dale Varberg, Edwin J. Purcell, Steven E. Rigdon','Prentice Hall','0130811378','978-0130811370');
|
||||
INSERT INTO book VALUES ('Algebra and Trigonometry Enhanced With Graphing Utilities','paperback',673,'English','Michael, III Sullivan','Prentice Hall College Div','0130853127','978-0130853127');
|
||||
INSERT INTO book VALUES ('Euclid s Elements','paperback',527,'English','T.L. Heath Translation','Green Lion Press ','1888009195','978-1888009194');
|
||||
INSERT INTO book VALUES ('A Beginner s Guide to Constructing the Universe: The Mathematical Archetypes of Nature, Art, and Science','paperback',224,'English','Michael S. Schneider','Harpercollins','0060169397','978-0060169398');
|
||||
INSERT INTO book VALUES ('Algebra and Trigonometry with Analytic Geometry (with CengageNOW Printed Access Card)','paperback',1023,'English','Earl W. Swokowski, Jeffery A. Cole','Brooks Cole','049510826X','978-0495108269');
|
||||
|
||||
|
||||
/***************************
|
||||
|
||||
Science (physics)
|
||||
|
||||
***************************/
|
||||
|
||||
INSERT INTO book VALUES ('Sidelights On Relativity','paperback',26,'English','Albert Einstein','Kessinger Publishing, LLC ','1169173802','978-1169173804');
|
||||
INSERT INTO book VALUES ('Kaplan MCAT Physics Review','paperback',576,'English','Kaplan','Kaplan Publishing','1607146428','978-1607146421');
|
||||
INSERT INTO book VALUES ('Physics of the Impossible: A Scientific Exploration into the World of Phasers, Force Fields, Teleportation, and Time Travel','paperback',352,'English','Michio Kaku','Anchor','0307278824','978-0307278821');
|
||||
INSERT INTO book VALUES ('Experiments With Alternate Currents of High Potential and High Frequency','paperback',72,'English','Nikola Tesla','General Books LLC ','1770450718','978-1770450714');
|
||||
INSERT INTO book VALUES ('The Elegant Universe: Superstrings, Hidden Dimensions, and the Quest for the Ultimate Theory','paperback',464,'English','Brian Greene','W. W. Norton & Company ','0393058581','978-0393058581');
|
||||
INSERT INTO book VALUES ('Conceptual Physics (11th Edition)','paperback',816,'English','Paul G. Hewitt','Addison Wesley','0321568095','978-0321568090');
|
||||
INSERT INTO book VALUES ('A Briefer History of Time','paperback',176,'English','Stephen Hawking, Leonard Mlodinow','Bantam','0553804367','978-0553804362');
|
||||
INSERT INTO book VALUES ('Physics for Scientists and Engineers: A Strategic Approach, Vol 5 (Chs 37-43) with MasteringPhysics (2nd Edition) (v. 5, Chapters 37-43)','paperback',80,'English','Randall D. Knight','Addison Wesley','0321516664','978-0321516664');
|
||||
INSERT INTO book VALUES ('ExamKrackers: Complete MCAT Study Package (5 vol. set)','paperback',980,'English','Jonathan Orsay','Osote Publishing','1893858200','978-1893858206');
|
||||
INSERT INTO book VALUES ('A Brief History of Time','paperback',224,'English','Stephen Hawking','Bantam','0553109537','978-0553109535');
|
||||
INSERT INTO book VALUES ('The Hidden Reality: Parallel Universes and the Deep Laws of the Cosmos','paperback',384,'English','Brian Greene','Knopf ','0307265633','978-0307265630');
|
||||
|
||||
/***************************
|
||||
|
||||
General readings
|
||||
|
||||
***************************/
|
||||
|
||||
INSERT INTO book VALUES ('Frankenstein (Cambridge Literature)','paperback',286,'English','Mary Shelley','Cambridge University Press ','0521587026','978-0521587020');
|
||||
INSERT INTO book VALUES ('Curious Folks Ask: 162 Real Answers on Amazing Inventions, Fascinating Products, and Medical Mysteries','paperback',224,'English','Sherry Seethaler','FT Press','0137057385','978-0137057382');
|
||||
INSERT INTO book VALUES ('Math for Moms and Dads: A dictionary of terms and concepts...just for parents','paperback',208,'English','Kaplan','Kaplan Publishing','1427798192','978-1427798190');
|
||||
INSERT INTO book VALUES ('See Me After Class: Advice for Teachers by Teachers','paperback',244,'English','Roxanna Elden','Kaplan Publishing ','1607140578','978-1607140573');
|
||||
INSERT INTO book VALUES ('Get Into Graduate School','paperback',312,'English','Kaplan','Kaplan Publishing','1419550101','978-1419550102');
|
||||
INSERT INTO book VALUES ('Pride And Prejudice','paperback',256,'English','Jane Austen','Tribeca Books ','1936594293','978-1936594290');
|
||||
INSERT INTO book VALUES ('Alice in Wonderland','paperback',100,'English','Lewis Carroll','Tribeca Books ','193659420X','978-1936594207');
|
||||
INSERT INTO book VALUES ('Dracula','paperback',364,'English','Bram Stoker','SoHo Books ','1936594331','978-1936594337');
|
||||
INSERT INTO book VALUES ('The Autobiography of Benjamin Franklin','paperback',152,'English','Benjamin Franklin','Tribeca Books ','1936594374','978-1936594375');
|
||||
INSERT INTO book VALUES ('The Scarlet Letter','paperback',140,'English','Nathaniel Hawthorne','Tribeca Books ','1936594277','978-1936594276');
|
||||
INSERT INTO book VALUES ('A Tale of Two Cities','paperback',428,'English','Charles Dickens','Simon & Brown ','1936041715','978-1936041718');
|
||||
INSERT INTO book VALUES ('Stuck in the Middle (Thorndike Press Large Print Christian Fiction)','paperback',434,'English','Virginia Smith','Thorndike Press','1410426645','978-1410426642');
|
||||
INSERT INTO book VALUES ('The Apothecary s Daughter (Superior Collection)','paperback',663,'English','Julie Klassen','Large Print Press','1410417115','978-1410417114');
|
||||
INSERT INTO book VALUES ('A Christmas Carol','paperback',110,'English','Charles Dickens','Tribeca Books ','193659434X','978-1936594344');
|
||||
INSERT INTO book VALUES ('Great Expectations (Oberon Book)','paperback',96,'English','Charles Dickens','Oberon Books ','1840027266','978-1840027266');
|
||||
INSERT INTO book VALUES ('The Art of Client Service: 58 Things Every Advertising & Marketing Professional Should Know, Revised and Updated Edition','paperback',208,'English','Robert Solomon','Kaplan Publishing','1427796718','978-1427796714');
|
||||
INSERT INTO book VALUES ('The Ultimate Sales Machine: Turbocharge Your Business with Relentless Focus on 12 Key Strategies','paperback',272,'English','Chet Holmes','Portfolio Trade ','1591842158','978-1591842156');
|
||||
INSERT INTO book VALUES ('The New Strategic Selling: The Unique Sales System Proven Successful by the World s Best Companies','paperback',448,'English','Stephen E. Heiman, Tad Tuleja','Business Plus','044669519X','978-0446695190');
|
||||
INSERT INTO book VALUES ('Smart Calling: Eliminate the Fear, Failure, and Rejection From Cold Calling','paperback',256,'English','Art Sobczak','Wiley ','0470567023','978-0470567029');
|
||||
INSERT INTO book VALUES ('Selling: Building Partnerships','paperback',552,'English','Barton Weitz, Stephen Castleberry, John Tanner','McGraw-Hill/Irwin','007338108X','978-0073381084');
|
||||
INSERT INTO book VALUES ('Selling Today (11th Edition)','paperback',544,'English','Gerald L Manning, Barry L Reece, Michael Ahearne','Prentice Hall','013207995X','978-0132079952');
|
||||
INSERT INTO book VALUES ('The Accidental Salesperson: How to Take Control of Your Sales Career and Earn the Respect and Income You Deserve','paperback',204,'English','Chris Lytle','AMACOM','0814470831','978-0814470831');
|
||||
INSERT INTO book VALUES ('Storyselling for Financial Advisors : How Top Producers Sell','paperback',256,'English','Scott West, Mitch Anthony','Kaplan Business ','0793136644','978-0793136643');
|
||||
INSERT INTO book VALUES ('Mastering the Complex Sale: How to Compete and Win When the Stakes are High!','paperback',304,'English','Jeff Thull','Wiley','0470533110','978-0470533116');
|
11
labs/cs2102/cases/Book Exchange/NUNStAClean.sql
Normal file
11
labs/cs2102/cases/Book Exchange/NUNStAClean.sql
Normal file
@ -0,0 +1,11 @@
|
||||
/*******************
|
||||
|
||||
Cleaning script
|
||||
|
||||
*******************/
|
||||
|
||||
DROP TABLE IF EXISTS loan;
|
||||
DROP TABLE IF EXISTS copy;
|
||||
DROP TABLE IF EXISTS student;
|
||||
DROP TABLE IF EXISTS book;
|
||||
DROP TABLE IF EXISTS department;
|
1252
labs/cs2102/cases/Book Exchange/NUNStACopy.sql
Normal file
1252
labs/cs2102/cases/Book Exchange/NUNStACopy.sql
Normal file
File diff suppressed because it is too large
Load Diff
2890
labs/cs2102/cases/Book Exchange/NUNStALoan.sql
Normal file
2890
labs/cs2102/cases/Book Exchange/NUNStALoan.sql
Normal file
File diff suppressed because it is too large
Load Diff
50
labs/cs2102/cases/Book Exchange/NUNStASchema (no bug).sql
Normal file
50
labs/cs2102/cases/Book Exchange/NUNStASchema (no bug).sql
Normal file
@ -0,0 +1,50 @@
|
||||
/*******************
|
||||
|
||||
Create the schema
|
||||
|
||||
********************/
|
||||
|
||||
CREATE TABLE IF NOT EXISTS book (
|
||||
title VARCHAR(256) NOT NULL,
|
||||
format CHAR(9) CONSTRAINT format CHECK(format = 'paperback' OR format='hardcover'),
|
||||
pages INT,
|
||||
language VARCHAR(32),
|
||||
authors VARCHAR(256),
|
||||
publisher VARCHAR(64),
|
||||
ISBN10 CHAR(10) NOT NULL UNIQUE,
|
||||
ISBN13 CHAR(14) PRIMARY KEY
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS student (
|
||||
name VARCHAR(32) NOT NULL,
|
||||
email VARCHAR(256) PRIMARY KEY,
|
||||
year DATE NOT NULL,
|
||||
faculty VARCHAR(62) NOT NULL,
|
||||
department VARCHAR(32) NOT NULL,
|
||||
graduate DATE,
|
||||
CHECK(graduate >= year)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS copy (
|
||||
owner VARCHAR(256) REFERENCES student(email) ON DELETE CASCADE DEFERRABLE,
|
||||
book CHAR(14) REFERENCES book(ISBN13) DEFERRABLE,
|
||||
copy INT CHECK(copy>0),
|
||||
PRIMARY KEY (owner, book, copy)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS loan (
|
||||
borrower VARCHAR(256) REFERENCES student(email) DEFERRABLE,
|
||||
owner VARCHAR(256),
|
||||
book CHAR(14),
|
||||
copy INT,
|
||||
borrowed DATE,
|
||||
returned DATE,
|
||||
FOREIGN KEY (owner, book, copy) REFERENCES copy(owner, book, copy) ON DELETE CASCADE DEFERRABLE,
|
||||
PRIMARY KEY (borrowed, borrower, owner, book, copy),
|
||||
CHECK(returned >= borrowed)
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
48
labs/cs2102/cases/Book Exchange/NUNStASchema.sql
Normal file
48
labs/cs2102/cases/Book Exchange/NUNStASchema.sql
Normal file
@ -0,0 +1,48 @@
|
||||
/*******************
|
||||
|
||||
Create the schema
|
||||
|
||||
********************/
|
||||
|
||||
CREATE TABLE IF NOT EXISTS book (
|
||||
title VARCHAR(256) NOT NULL,
|
||||
format CHAR(9) CONSTRAINT format CHECK(format = 'paperback' OR format='hardcover'),
|
||||
pages INT,
|
||||
language VARCHAR(32),
|
||||
authors VARCHAR(256),
|
||||
publisher VARCHAR(64),
|
||||
ISBN10 CHAR(10) NOT NULL UNIQUE,
|
||||
ISBN13 CHAR(14) PRIMARY KEY
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS student (
|
||||
name VARCHAR(32) NOT NULL,
|
||||
email VARCHAR(256) PRIMARY KEY,
|
||||
year DATE NOT NULL,
|
||||
faculty VARCHAR(62) NOT NULL,
|
||||
department VARCHAR(32) NOT NULL,
|
||||
graduate DATE,
|
||||
CHECK(graduate >= year)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS loan (
|
||||
borrower VARCHAR(256) REFERENCES student(email) DEFERRABLE,
|
||||
owner VARCHAR(256),
|
||||
book CHAR(14),
|
||||
copy INT,
|
||||
borrowed DATE,
|
||||
returned DATE,
|
||||
FOREIGN KEY (owner, book, copy) REFERENCES copy(owner, book, copy) ON DELETE CASCADE DEFERRABLE,
|
||||
PRIMARY KEY (borrowed, borrower, owner, book, copy),
|
||||
CHECK(returned >= borrowed)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS copy (
|
||||
owner VARCHAR(256) REFERENCES student(email) ON DELETE CASCADE DEFERRABLE,
|
||||
book CHAR(14) REFERENCES book(ISBN13) DEFERRABLE,
|
||||
copy INT CHECK(copy>0),
|
||||
PRIMARY KEY (owner, book, copy)
|
||||
);
|
||||
|
||||
|
||||
|
109
labs/cs2102/cases/Book Exchange/NUNStAStudent.sql
Normal file
109
labs/cs2102/cases/Book Exchange/NUNStAStudent.sql
Normal file
@ -0,0 +1,109 @@
|
||||
/***************************
|
||||
|
||||
Populate the student table
|
||||
|
||||
****************************/
|
||||
|
||||
INSERT INTO student VALUES ('XIE XIN', 'xiexin2011@gmail.com', '2018-08-01', 'Faculty of Science', 'Chemistry', NULL);
|
||||
INSERT INTO student VALUES ('HUANG RAN', 'huangran1991@yahoo.com', '2018-08-01', 'Faculty of Science', 'Biology', NULL);
|
||||
INSERT INTO student VALUES ('GOH ENG CHYE', 'gohengchye1992@msn.com', '2018-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('GOH HUI YING', 'gohhuiying1989@gmail.com', '2019-08-01', 'Faculty of Science', 'Biology', NULL);
|
||||
INSERT INTO student VALUES ('FANG HAN', 'fanghan2011@hotmail.com', '2019-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('DING KUAN CHONG', 'dingkuanchong2010@msn.com', '2019-08-01', 'Faculty of Engineering', 'CE', NULL);
|
||||
INSERT INTO student VALUES ('TAY WEI GUO', 'tayweiguo1989@msn.com', '2021-08-01', 'Faculty of Engineering', 'CE', NULL);
|
||||
INSERT INTO student VALUES ('ONG KAH HONG', 'ongkahhong1991@gmail.com', '2019-08-01', 'Faculty of Science', 'Math', NULL);
|
||||
INSERT INTO student VALUES ('PENG JIAYUAN', 'pengjiayuan2011@hotmail.com', '2019-08-01', 'Faculty of Science', 'Biology', NULL);
|
||||
INSERT INTO student VALUES ('HUANG ZHANPENG', 'huangzhanpeng1992@msn.com', '2021-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('NGOO GEK PING', 'ngoogekping1990@hotmail.com', '2020-08-01', 'Faculty of Science', 'Biology', NULL);
|
||||
INSERT INTO student VALUES ('GE YUWEI', 'geyuwei1992@hotmail.com', '2020-08-01', 'Faculty of Science', 'Physics', NULL);
|
||||
INSERT INTO student VALUES ('ZHENG ZHEMIN', 'zhengzhemin1991@yahoo.com', '2019-08-01', 'Faculty of Arts and Social Science', 'History', NULL);
|
||||
INSERT INTO student VALUES ('LIU ZHANPENG', 'liuzhanpeng2011@msn.com', '2018-08-01', 'Faculty of Science', 'Chemistry', NULL);
|
||||
INSERT INTO student VALUES ('HUANG WENXIN', 'huangwenxin2010@msn.com', '2019-08-01', 'Faculty of Science', 'Math', NULL);
|
||||
INSERT INTO student VALUES ('CHOY WEI XIANG', 'choyweixiang2011@gmail.com', '2019-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('WANG NA', 'wangna1990@yahoo.com', '2021-08-01', 'Faculty of Science', 'Chemistry', NULL);
|
||||
INSERT INTO student VALUES ('ZHOU HUICHAN', 'zhouhuichan1990@msn.com', '2019-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('NG ANH QUANG', 'nganhquang1991@yahoo.com', '2020-08-01', 'Faculty of Engineering', 'ME', NULL);
|
||||
INSERT INTO student VALUES ('HUANG QI', 'huangqi1990@msn.com', '2021-08-01', 'School of Computing', 'IS', NULL);
|
||||
INSERT INTO student VALUES ('DING GEK PING', 'dinggekping1991@msn.com', '2018-08-01', 'Faculty of Science', 'Physics', NULL);
|
||||
INSERT INTO student VALUES ('POH HUI LING', 'pohhuiling1992@hotmail.com', '2018-08-01', 'Faculty of Science', 'Biology', NULL);
|
||||
INSERT INTO student VALUES ('NG QI YANG', 'ngqiyang1989@msn.com', '2020-08-01', 'Faculty of Engineering', 'CE', NULL);
|
||||
INSERT INTO student VALUES ('NEELAM DEOL', 'neelamdeol2011@hotmail.com', '2019-08-01', 'Faculty of Arts and Social Science', 'Language', NULL);
|
||||
INSERT INTO student VALUES ('LI YUZHAO', 'liyuzhao1990@gmail.com', '2020-08-01', 'Faculty of Arts and Social Science', 'Economics', NULL);
|
||||
INSERT INTO student VALUES ('VARGHESE ANEJA', 'vargheseaneja1992@msn.com', '2021-08-01', 'School of Computing', 'IS', NULL);
|
||||
INSERT INTO student VALUES ('LIU SHAOJUN', 'liushaojun2010@msn.com', '2018-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('QIN YIYANG', 'qinyiyang2010@hotmail.com', '2018-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('ZHOU CONG', 'zhoucong1990@yahoo.com', '2021-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('TAY YONG MING', 'tayyongming1989@gmail.com', '2020-08-01', 'Faculty of Engineering', 'CE', NULL);
|
||||
INSERT INTO student VALUES ('SIOW CAO KHOA', 'siowcaokhoa1991@msn.com', '2021-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('NI HANRAN', 'nihanran1989@msn.com', '2018-08-01', 'Faculty of Science', 'Physics', NULL);
|
||||
INSERT INTO student VALUES ('CHOY YI TING', 'choyyiting1992@hotmail.com', '2020-08-01', 'Faculty of Science', 'Biology', NULL);
|
||||
INSERT INTO student VALUES ('DENNIS BECKHAM', 'dennisbeckham1989@msn.com', '2021-08-01', 'School of Computing', 'IS', NULL);
|
||||
INSERT INTO student VALUES ('ZHANG ZHUO', 'zhangzhuo1989@hotmail.com', '2018-08-01', 'Faculty of Science', 'Math', NULL);
|
||||
INSERT INTO student VALUES ('ANUPAMA ANGHAN', 'anupamaanghan2010@yahoo.com', '2020-08-01', 'Faculty of Engineering', 'CE', NULL);
|
||||
INSERT INTO student VALUES ('LIU QIAN', 'liuqian1991@yahoo.com', '2020-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('ZHANG YINGBO', 'zhangyingbo1989@msn.com', '2021-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('CHIA YEU ARNG', 'chiayeuarng1991@hotmail.com', '2019-08-01', 'Faculty of Science', 'Math', NULL);
|
||||
INSERT INTO student VALUES ('ZENG YIHUI', 'zengyihui2010@yahoo.com', '2019-08-01', 'Faculty of Arts and Social Science', 'History', NULL);
|
||||
INSERT INTO student VALUES ('FENG MENG', 'fengmeng1990@gmail.com', '2018-08-01', 'Faculty of Science', 'Biology', NULL);
|
||||
INSERT INTO student VALUES ('ZHANG HAN', 'zhanghan1989@hotmail.com', '2019-08-01', 'Faculty of Arts and Social Science', 'History', NULL);
|
||||
INSERT INTO student VALUES ('LIU DANNI', 'liudanni1991@yahoo.com', '2021-08-01', 'Faculty of Engineering', 'ME', NULL);
|
||||
INSERT INTO student VALUES ('SOH JIE FENG', 'sohjiefeng1991@msn.com', '2021-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('TAN CHENG HAN', 'tanchenghan1990@msn.com', '2018-08-01', 'Faculty of Science', 'Physics', NULL);
|
||||
INSERT INTO student VALUES ('JENNY HUNT', 'jennyhunt1991@gmail.com', '2019-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('DING YANG', 'dingyang1989@gmail.com', '2021-08-01', 'Faculty of Arts and Social Science', 'History', NULL);
|
||||
INSERT INTO student VALUES ('ZHANG HONG', 'zhanghong2011@msn.com', '2021-08-01', 'School of Computing', 'IS', NULL);
|
||||
INSERT INTO student VALUES ('XU HUAJUN', 'xuhuajun1990@msn.com', '2021-08-01', 'School of Computing', 'IS', NULL);
|
||||
INSERT INTO student VALUES ('SOMESH ANEJA', 'someshaneja2011@yahoo.com', '2018-08-01', 'Faculty of Engineering', 'EE', NULL);
|
||||
INSERT INTO student VALUES ('SEAH TECK KEE', 'seahteckkee1990@gmail.com', '2019-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('LIU YIHUI', 'liuyihui1990@hotmail.com', '2019-08-01', 'Faculty of Science', 'Biology', NULL);
|
||||
INSERT INTO student VALUES ('ZHU CHANG', 'zhuchang2010@gmail.com', '2020-08-01', 'Faculty of Arts and Social Science', 'History', NULL);
|
||||
INSERT INTO student VALUES ('ZHENG XI', 'zhengxi1990@yahoo.com', '2021-08-01', 'School of Computing', 'IS', NULL);
|
||||
INSERT INTO student VALUES ('YEO JIA HAO', 'yeojiahao1989@yahoo.com', '2021-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('ANNIE CHAPMAN', 'anniechapman1991@yahoo.com', '2019-08-01', 'Faculty of Arts and Social Science', 'Language', NULL);
|
||||
INSERT INTO student VALUES ('JERRY BROWN', 'jerrybrown2010@gmail.com', '2021-08-01', 'Faculty of Arts and Social Science', 'Economics', NULL);
|
||||
INSERT INTO student VALUES ('ZHOU XIALIN', 'zhouxialin1990@yahoo.com', '2019-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('TAN HUI LIN', 'tanhuilin1989@hotmail.com', '2018-08-01', 'School of Computing', 'IS', NULL);
|
||||
INSERT INTO student VALUES ('JENNY BECKHAM', 'jennybeckham1992@gmail.com', '2019-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('HENRY HUNT', 'henryhunt1992@yahoo.com', '2021-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('LIU JUN', 'liujun1992@msn.com', '2021-08-01', 'Faculty of Engineering', 'EE', NULL);
|
||||
INSERT INTO student VALUES ('ZHANG ZHANPENG', 'zhangzhanpeng1992@hotmail.com', '2018-08-01', 'Faculty of Science', 'Math', NULL);
|
||||
INSERT INTO student VALUES ('DAVID CHAPMAN', 'davidchapman1989@msn.com', '2019-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('QIN YUWEI', 'qinyuwei2011@hotmail.com', '2020-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('DENNIS PALMER', 'dennispalmer1992@yahoo.com', '2021-08-01', 'Faculty of Engineering', 'ME', NULL);
|
||||
INSERT INTO student VALUES ('KRUPESH ANDHAK', 'krupeshandhak1991@yahoo.com', '2021-08-01', 'School of Computing', 'IS', NULL);
|
||||
INSERT INTO student VALUES ('LEE YI JIA', 'leeyijia1989@gmail.com', '2018-08-01', 'Faculty of Science', 'Biology', NULL);
|
||||
INSERT INTO student VALUES ('DAVID HALL', 'davidhall1992@yahoo.com', '2020-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('SEAH WENG FAI', 'seahwengfai1990@yahoo.com', '2021-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('SHEN TIANYI', 'shentianyi1991@msn.com', '2020-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('WEN NA', 'wenna1990@msn.com', '2020-08-01', 'Faculty of Arts and Social Science', 'Economics', NULL);
|
||||
INSERT INTO student VALUES ('LIU LINXI', 'liulinxi1991@yahoo.com', '2020-08-01', 'Faculty of Arts and Social Science', 'Economics', NULL);
|
||||
INSERT INTO student VALUES ('DING WEI XIANG', 'dingweixiang1990@yahoo.com', '2021-08-01', 'School of Computing', 'IS', NULL);
|
||||
INSERT INTO student VALUES ('CHEW SOEN NAM', 'chewsoennam1989@msn.com', '2021-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('IRIS BROWN', 'irisbrown1992@hotmail.com', '2019-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('KEN OWEN', 'kenowen2011@yahoo.com', '2018-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('ZHANG YUZHAO', 'zhangyuzhao1990@gmail.com', '2020-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('GE DUO', 'geduo2010@yahoo.com', '2020-08-01', 'Faculty of Engineering', 'ME', NULL);
|
||||
INSERT INTO student VALUES ('HUANG XUANTI', 'huangxuanti1992@msn.com', '2018-08-01', 'School of Computing', 'IS', NULL);
|
||||
INSERT INTO student VALUES ('LISA SMITH', 'lisasmith2011@msn.com', '2018-08-01', 'Faculty of Science', 'Chemistry', NULL);
|
||||
INSERT INTO student VALUES ('CHOY JIAN MIN', 'choyjianmin1991@gmail.com', '2019-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('NG YONG MING', 'ngyongming2011@yahoo.com', '2020-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('ZHENG NANA', 'zhengnana1991@gmail.com', '2021-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('ZHAO YANG', 'zhaoyang1989@yahoo.com', '2019-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('NEHAL KANWAT', 'nehalkanwat1989@gmail.com', '2021-08-01', 'Faculty of Arts and Social Science', 'Language', NULL);
|
||||
INSERT INTO student VALUES ('NG YAN FEN', 'ngyanfen2010@msn.com', '2019-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('ANG JIA YI', 'angjiayi1990@hotmail.com', '2020-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('CHNG HUI LING', 'chnghuiling1992@gmail.com', '2020-08-01', 'Faculty of Arts and Social Science', 'History', NULL);
|
||||
INSERT INTO student VALUES ('TAN WEI SHENG', 'tanweisheng1989@gmail.com', '2021-08-01', 'Faculty of Arts and Social Science', 'Geography', NULL);
|
||||
INSERT INTO student VALUES ('LIEW LIEN LER', 'liewlienler2010@yahoo.com', '2021-08-01', 'Faculty of Engineering', 'CE', NULL);
|
||||
INSERT INTO student VALUES ('NGOO KAI TING', 'ngookaiting1991@yahoo.com', '2021-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('LIU JUN', 'liujun1989@msn.com', '2018-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('SHEN WANTING', 'shenwanting2011@yahoo.com', '2020-08-01', 'Faculty of Engineering', 'CE', NULL);
|
||||
INSERT INTO student VALUES ('ZHANG CONG', 'zhangcong2010@hotmail.com', '2021-08-01', 'Faculty of Engineering', 'EE', NULL);
|
||||
INSERT INTO student VALUES ('SUBRAMANIAM GHANTASALA', 'subramaniamghantasala2011@msn.com', '2018-08-01', 'School of Computing', 'IS', NULL);
|
||||
INSERT INTO student VALUES ('TSO HUI LIN', 'tsohuilin1989@msn.com', '2018-08-01', 'Faculty of Science', 'Physics', NULL);
|
||||
INSERT INTO student VALUES ('CHIA WEI GUO', 'chiaweiguo1990@hotmail.com', '2019-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('LIU YIYANG', 'liuyiyang1992@msn.com', '2021-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('LIU ZHENCAI', 'liuzhencai1990@msn.com', '2021-08-01', 'School of Computing', 'CS', NULL);
|
||||
INSERT INTO student VALUES ('GERALDINE LEE', 'glee@msn.com', '2018-08-01', 'School of Computing', 'IS', '2021-07-31');
|
||||
INSERT INTO student VALUES ('ADELINE WONG', 'awong007@msn.com', '2018-08-01', 'School of Computing', 'CS', '2021-07-31');
|
||||
INSERT INTO student VALUES ('TANG CHEE YONG', 'tcy@hotmail.com', '2018-08-01', 'School of Computing', 'IS', '2021-07-31');
|
8
labs/cs2102/justfile
Normal file
8
labs/cs2102/justfile
Normal file
@ -0,0 +1,8 @@
|
||||
init:
|
||||
docker run --name pg -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres
|
||||
|
||||
psql *ARGS:
|
||||
docker exec -it pg psql -U postgres {{ARGS}}
|
||||
|
||||
rm:
|
||||
docker container rm --force pg
|
@ -0,0 +1,98 @@
|
||||
SELECT r.bib, s.nr, SUM(rs.points)
|
||||
FROM riders r, results_sprints rs, stages s
|
||||
WHERE r.bib = rs.rider
|
||||
AND rs.stage <= s.nr
|
||||
GROUP BY r.bib, s.nr
|
||||
ORDER BY r.bib ASC, s.nr ASC;
|
||||
|
||||
-- Q9
|
||||
SELECT SUM(s.length)
|
||||
FROM stages s
|
||||
WHERE s.nr <=10;
|
||||
|
||||
-- Q10
|
||||
SELECT DISTINCT l.name, l.country
|
||||
FROM stages s, locations l
|
||||
WHERE s.start = l.name
|
||||
OR s.finish = l.name;
|
||||
|
||||
SELECT l.name, l.country
|
||||
FROM locations l
|
||||
WHERE l.name IN (SELECT s.start FROM stages s)
|
||||
OR l.name IN (SELECT s.finish FROM stages s);
|
||||
|
||||
-- Q11
|
||||
SELECT r.bib, r.name
|
||||
FROM riders r
|
||||
WHERE r.bib NOT IN (
|
||||
SELECT ri.rider
|
||||
FROM results_individual ri
|
||||
WHERE stage = 1
|
||||
);
|
||||
|
||||
-- Q12
|
||||
SELECT r.bib, r.name
|
||||
FROM riders r
|
||||
EXCEPT
|
||||
SELECT r.bib, r.name
|
||||
FROM riders r, results_individual ri
|
||||
WHERE r.bib = ri.rider
|
||||
AND ri.stage = 1;
|
||||
|
||||
-- Q13
|
||||
SELECT r.bib, r.name
|
||||
FROM riders r
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM results_individual ri
|
||||
WHERE stage = 1
|
||||
AND r.bib = ri.rider
|
||||
);
|
||||
-- Q14
|
||||
SELECT *
|
||||
FROM riders r
|
||||
LEFT OUTER JOIN results_individual ri on ri.rider = r.bib
|
||||
WHERE ri.rider ISNULL;
|
||||
|
||||
-- Q15
|
||||
|
||||
|
||||
-- Simple
|
||||
-- Algebriaic
|
||||
-- aggregate
|
||||
-- nested
|
||||
|
||||
-- Q16
|
||||
SELECT r.name, s.nr
|
||||
FROM stages s, riders r
|
||||
WHERE r.bib NOT IN (
|
||||
SELECT ri.rider
|
||||
FROM results_individual ri
|
||||
WHERE stage = s.nr
|
||||
AND r.bib = ri.rider
|
||||
)
|
||||
ORDER BY s.nr ASC, r.name ASC;
|
||||
|
||||
SELECT *
|
||||
FROM riders r, results_individual ri
|
||||
WHERE r.bib = ri.rider
|
||||
GROUP BY
|
||||
|
||||
-- Q17
|
||||
SELECT *
|
||||
FROM stages s
|
||||
LEFT OUTER JOIN mountains m ON s.nr = m.stage
|
||||
AND m.category = '3'
|
||||
ORDER BY s.nr ASC
|
||||
|
||||
|
||||
|
||||
-- SELECT DISTINCT
|
||||
-- WHERE ALL
|
||||
-- WHERE IN
|
||||
-- WHERE NOT IN
|
||||
-- WHERE EXISTS
|
||||
-- WHERE NOT EXISTS
|
||||
-- DOUBLE WHERE NOT EXISTS (WHERE ALL)
|
||||
-- Select top N by category
|
||||
--
|
133
labs/cs2102/project/cs2102-2310-project-schema.sql
Normal file
133
labs/cs2102/project/cs2102-2310-project-schema.sql
Normal file
@ -0,0 +1,133 @@
|
||||
|
||||
DROP TABLE IF EXISTS submitted_answers;
|
||||
DROP TABLE IF EXISTS submissions;
|
||||
DROP TABLE IF EXISTS answers;
|
||||
DROP TABLE IF EXISTS student_groups;
|
||||
DROP TABLE IF EXISTS quiz_groups;
|
||||
DROP TABLE IF EXISTS quiz_questions;
|
||||
DROP TABLE IF EXISTS quizzes;
|
||||
DROP TABLE IF EXISTS question_tags;
|
||||
DROP TABLE IF EXISTS questions;
|
||||
DROP TABLE IF EXISTS students;
|
||||
DROP TABLE IF EXISTS educators;
|
||||
DROP TABLE IF EXISTS groups;
|
||||
DROP TABLE IF EXISTS tags;
|
||||
|
||||
|
||||
CREATE TABLE tags (
|
||||
text VARCHAR(255) PRIMARY KEY
|
||||
);
|
||||
|
||||
CREATE TABLE groups (
|
||||
code INT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE educators (
|
||||
staff_nr VARCHAR(5) PRIMARY KEY,
|
||||
first_name VARCHAR(255) NOT NULL,
|
||||
last_name VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE students (
|
||||
student_nr VARCHAR(10) PRIMARY KEY,
|
||||
first_name VARCHAR(255) NOT NULL,
|
||||
last_name VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
last_active DATE
|
||||
);
|
||||
|
||||
CREATE TABLE questions (
|
||||
id INT PRIMARY KEY,
|
||||
statement TEXT NOT NULL,
|
||||
description TEXT,
|
||||
type VARCHAR(255) NOT NULL CHECK(type IN ('MCQ', 'MRQ')),
|
||||
status VARCHAR(255) NOT NULL CHECK(status IN ('private', 'public')),
|
||||
valid BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
creator VARCHAR(10),
|
||||
FOREIGN KEY (creator) REFERENCES educators (staff_nr)
|
||||
);
|
||||
|
||||
CREATE TABLE question_tags (
|
||||
question_id INT,
|
||||
text VARCHAR(255),
|
||||
PRIMARY KEY (question_id, text),
|
||||
FOREIGN KEY (question_id) REFERENCES questions (id),
|
||||
FOREIGN KEY (text) REFERENCES tags(text)
|
||||
);
|
||||
|
||||
CREATE TABLE quizzes (
|
||||
id INT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
published BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
num_attempts INT DEFAULT NULL, -- NULL=unlimited
|
||||
avail_from DATE DEFAULT NOW(), -- by default immediately available
|
||||
avail_to DATE, -- NULL=no expiry date/time
|
||||
total_points INT NOT NULL DEFAULT 0, -- needs to be automatically set!
|
||||
time_limit INT DEFAULT NULL CHECK (time_limit > 0), -- time limit in seconds (NULL=unlimited)
|
||||
mandatory BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
status VARCHAR(255) NOT NULL CHECK(status IN ('private', 'public')),
|
||||
creator VARCHAR(10) NOT NULL,
|
||||
FOREIGN KEY (creator) REFERENCES educators (staff_nr),
|
||||
CONSTRAINT availability_check CHECK (avail_to IS NULL OR avail_to >= avail_from)
|
||||
);
|
||||
|
||||
CREATE TABLE quiz_questions (
|
||||
quiz_id INT,
|
||||
question_id INT,
|
||||
points INT NOT NULL DEFAULT 0 CHECK (points >= 0),
|
||||
mandatory BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
position INT NOT NULL,
|
||||
PRIMARY KEY (question_id, quiz_id),
|
||||
FOREIGN KEY (question_id) REFERENCES questions (id),
|
||||
FOREIGN KEY (quiz_id) REFERENCES quizzes (id),
|
||||
CONSTRAINT unique_questions_position UNIQUE (quiz_id, position)
|
||||
);
|
||||
|
||||
CREATE TABLE quiz_groups (
|
||||
quiz_id INT,
|
||||
group_code INT,
|
||||
PRIMARY KEY (quiz_id, group_code),
|
||||
FOREIGN KEY (quiz_id) REFERENCES quizzes (id),
|
||||
FOREIGN KEY (group_code) REFERENCES groups (code)
|
||||
);
|
||||
|
||||
CREATE TABLE student_groups (
|
||||
student_nr VARCHAR(10),
|
||||
group_code INT,
|
||||
PRIMARY KEY (student_nr, group_code),
|
||||
FOREIGN KEY (student_nr) REFERENCES students (student_nr),
|
||||
FOREIGN KEY (group_code) REFERENCES groups (code)
|
||||
);
|
||||
|
||||
CREATE TABLE answers (
|
||||
question_id INT,
|
||||
answer_id INT,
|
||||
content TEXT NOT NULL,
|
||||
position INT NOT NULL,
|
||||
correct BOOLEAN NOT NULL,
|
||||
PRIMARY KEY (question_id, answer_id),
|
||||
FOREIGN KEY (question_id) REFERENCES questions (id) ON DELETE CASCADE,
|
||||
CONSTRAINT unique_answer_position UNIQUE (question_id, position)
|
||||
);
|
||||
|
||||
CREATE TABLE submissions (
|
||||
id INT PRIMARY KEY,
|
||||
quiz_id INT NOT NULL,
|
||||
student_nr VARCHAR(5) NOT NULL,
|
||||
attempt INT NOT NULL CHECK (attempt > 0),
|
||||
FOREIGN KEY (quiz_id) REFERENCES quizzes (id),
|
||||
FOREIGN KEY (student_nr) REFERENCES students (student_nr)
|
||||
);
|
||||
|
||||
CREATE TABLE submitted_answers (
|
||||
question_id INT,
|
||||
answer_id INT,
|
||||
submission_id INT,
|
||||
PRIMARY KEY (question_id, answer_id, submission_id),
|
||||
FOREIGN KEY (question_id, answer_id) REFERENCES answers (question_id, answer_id),
|
||||
FOREIGN KEY (submission_id) REFERENCES submissions (id)
|
||||
);
|
||||
|
@ -0,0 +1,100 @@
|
||||
CREATE OR REPLACE PROCEDURE create_practice_quiz(
|
||||
quiz_name VARCHAR,
|
||||
creator_id VARCHAR,
|
||||
num_questions INT,
|
||||
) AS
|
||||
$$
|
||||
DECLARE
|
||||
quiz_id INT;
|
||||
c CURSOR FOR (SELECT * FROM quiz_questions);
|
||||
quiz_qn RECORD;
|
||||
random_no INT;
|
||||
num_qns INT = (SELECT COUNT(*) FROM questions);
|
||||
BEGIN
|
||||
INSERT INTO quizzes (id, name, published, total_points, avail_from, avail_to, time_limit, mandatory, status,
|
||||
creator)
|
||||
values ((SELECT id + 1 FROM quizzes ORDER BY id DESC LIMIT 1), -- get last id
|
||||
quiz_name,
|
||||
true,
|
||||
0,
|
||||
NOW(),
|
||||
NULL,
|
||||
NULL,
|
||||
FALSE,
|
||||
'public',
|
||||
creator_id)
|
||||
RETURNING id
|
||||
INTO quiz_id;
|
||||
OPEN c;
|
||||
FOR val IN 1..num_questions LOOP
|
||||
random_no = FLOOR(random() * (num_questions));
|
||||
END LOOP;
|
||||
CLOSE c;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE PROCEDURE create_practice_quiz (
|
||||
quiz_name varchar,
|
||||
creator_id varchar,
|
||||
num_questions int
|
||||
)
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
BEGIN
|
||||
WITH quiz AS (
|
||||
INSERT INTO quizzes (
|
||||
id,
|
||||
name,
|
||||
published,
|
||||
num_attempts,
|
||||
avail_from,
|
||||
total_points,
|
||||
mandatory,
|
||||
status,
|
||||
creator
|
||||
)
|
||||
VALUES (
|
||||
(SELECT count(*) + 1 FROM quizzes),
|
||||
quiz_name,
|
||||
true,
|
||||
0,
|
||||
now(),
|
||||
0,
|
||||
false,
|
||||
'public',
|
||||
creator_id
|
||||
)
|
||||
RETURNING
|
||||
id,
|
||||
status,
|
||||
creator
|
||||
)
|
||||
INSERT INTO quiz_questions (
|
||||
quiz_id,
|
||||
question_id,
|
||||
points,
|
||||
mandatory,
|
||||
position
|
||||
)
|
||||
SELECT
|
||||
q.id,
|
||||
qn.id,
|
||||
0,
|
||||
false,
|
||||
ROW_NUMBER() OVER (ORDER BY random())
|
||||
FROM
|
||||
questions qn,
|
||||
quiz q
|
||||
WHERE
|
||||
qn.valid = true
|
||||
AND (
|
||||
qn.status = 'public'
|
||||
OR qn.creator = q.creator
|
||||
)
|
||||
ORDER BY random()
|
||||
LIMIT num_questions;
|
||||
END
|
||||
$$;
|
||||
|
||||
SELECT FLOOR(random() * (SELECT COUNT(*) FROM questions));
|
Loading…
Reference in New Issue
Block a user