1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| create table account( account_id SERIAL PRIMARY KEY, account_name VARCHAR(20), first_name VARCHAR(20), last_name VARCHAR(20), email VARCHAR(1000), password_hash VARCHAR(64), protrait_image BLOB, hourly_rate NUMERIC(9,2) );
create table bug_stastus( status VARCHAR(20) PRIMARY KEY );
create table bug( bug_id SERIAL PRIMARY KEY, date_reported DATE NOT NULL, summary VARCHAR(80), description VARCHAR(1000), resolution VARCHAR(1000), reported_by BIGINT UNSIGNED NOT NULL, assigned_to BIGINT UNSIGNED, verified_by BIGINT UNSIGNED, status VARCHAR(20) NOT NULL DEFAULT 'NEW', priority VARCHAR(20), hours NUMERIC(9,2), FOREIGN KEY (reported_by) REFERENCES account(account_id), FOREIGN KEY (assigned_to) REFERENCES account(account_id), FOREIGN KEY (verified_by) REFERENCES account(account_id), FOREIGN KEY (status) REFERENCES bug_stastus(status) );
create table comments( comment_id SERIAL PRIMARY KEY, bug_id BIGINT UNSIGNED NOT NULL, author BIGINT UNSIGNED NOT NULL, comment_date DATETIME NOT NULL, comment TEXT NOT NULL, FOREIGN KEY (bug_id) REFERENCES bug(bug_id), FOREIGN KEY (author) REFERENCES account(account_id) );
create table screenshot( bug_id BIGINT UNSIGNED NOT NULL, image_id BIGINT UNSIGNED NOT NULL, screenshot_image BLOB, caption VARCHAR(100), PRIMARY KEY (bug_id,image_id), FOREIGN KEY (bug_id) REFERENCES bug(bug_id) );
create table tag( bug_id BIGINT UNSIGNED NOT NULL, tag VARCHAR(20) NOT NULL, PRIMARY KEY (bug_id,tag), FOREIGN KEY (bug_id) REFERENCES bug(bug_id) );
create table product( product_id SERIAL PRIMARY KEY, product_name VARCHAR(50) );
create table bug_product( bug_id BIGINT UNSIGNED NOT NULL, product_id BIGINT UNSIGNED NOT NULL, PRIMARY KEY (bug_id,product_id), FOREIGN KEY (bug_id) REFERENCES bug(bug_id), FOREIGN KEY (product_id) REFERENCES product(product_id) );
|