0% found this document useful (0 votes)
752 views

(CS2102) Database: Problem I Answer

This is the answer for CS2102 "Database" Problem 1 Answer for AY2011-12 Semester 2. Credit to Stephane Bressan and Tang Rui Ming. Just sharing it only.

Uploaded by

Francis Pang
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
752 views

(CS2102) Database: Problem I Answer

This is the answer for CS2102 "Database" Problem 1 Answer for AY2011-12 Semester 2. Credit to Stephane Bressan and Tang Rui Ming. Just sharing it only.

Uploaded by

Francis Pang
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

CS2102 Tutorial 1 Solution

CREATE TABLE members ( name VARCHAR(20) NOT NULL, card_number NUMERIC PRIMARY KEY, address VARCHAR(50) NOT NULL ) CREATE TABLE wines ( name VARCHAR(20), appellation VARCHAR(20), vintage NUMERIC, alcohol_degree NUMERIC NOT NULL, vineyard VARCHAR(100) NOT NULL, certifier VARCHAR(50) NOT NULL, country VARCHAR(20) NOT NULL, PRIMARY KEY (name, vintage, appellation) ) CREATE TABLE bottles ( wine_name VARCHAR(20), vintage NUMERIC, appellation VARCHAR(20), number NUMERIC, in_cellar BOOLEAN NOT NULL, PRIMARY KEY (number, wine_name, vintage, appellation), FOREIGN KEY (wine_name, vintage, appellation) REFERENCES wines(name, vintage, appellation)) CREATE TABLE taste ( Member NUMERIC(20), wine_name VARCHAR(20), vintage NUMERIC, appellation VARCHAR(20), rating VARCHAR(9) NOT NULL, bottle_no NUMERIC, date DATE NOT NULL, PRIMARY KEY (member, bottle_no, wine_name, vintage, appellation), FOREIGN KEY member REFERENCES members(card_number), FOREIGN KEY (bottle_no, wine_name, vintage, appellation) REFERENCES bottles(number, name, vintage, appellation))

number

member

taste

bottle

name address card_number

date

rating

contain

appellation name vintage

wine

Other

You might also like