File size: 13,742 Bytes
2abe051 |
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
);
INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('CD', 'b');
INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('Paper', 'u');
INSERT INTO Ref_Document_Types (`document_type_code`, `document_type_description`) VALUES ('Hard Drive', 'f');
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
);
INSERT INTO Roles (`role_code`, `role_description`) VALUES ('ED', 'Editor');
INSERT INTO Roles (`role_code`, `role_description`) VALUES ('PT', 'Photo');
INSERT INTO Roles (`role_code`, `role_description`) VALUES ('MG', 'Manager');
INSERT INTO Roles (`role_code`, `role_description`) VALUES ('PR', 'Proof Manager');
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
);
INSERT INTO Addresses (`address_id`, `address_details`) VALUES (0, 'IT');
INSERT INTO Addresses (`address_id`, `address_details`) VALUES (1, 'MX');
INSERT INTO Addresses (`address_id`, `address_details`) VALUES (2, 'DE');
INSERT INTO Addresses (`address_id`, `address_details`) VALUES (3, 'ES');
INSERT INTO Addresses (`address_id`, `address_details`) VALUES (4, 'ES');
INSERT INTO Addresses (`address_id`, `address_details`) VALUES (5, 'IE');
INSERT INTO Addresses (`address_id`, `address_details`) VALUES (6, 'US');
INSERT INTO Addresses (`address_id`, `address_details`) VALUES (7, 'PT');
INSERT INTO Addresses (`address_id`, `address_details`) VALUES (8, 'IE');
INSERT INTO Addresses (`address_id`, `address_details`) VALUES (9, 'MX');
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
);
INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('working', 'currently working on');
INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('done', 'mailed');
INSERT INTO Ref_Document_Status (`document_status_code`, `document_status_description`) VALUES ('overdue', 'mailed late');
CREATE TABLE Ref_Shipping_Agents (
shipping_agent_code CHAR(15) NOT NULL,
shipping_agent_name VARCHAR(255) NOT NULL,
shipping_agent_description VARCHAR(255) NOT NULL,
PRIMARY KEY (shipping_agent_code)
);
INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('UP', 'UPS', 'g');
INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('US', 'USPS', 'q');
INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('AL', 'Airline', 'w');
INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('FE', 'Fedex', 'k');
INSERT INTO Ref_Shipping_Agents (`shipping_agent_code`, `shipping_agent_name`, `shipping_agent_description`) VALUES ('SH', 'Ship', 't');
CREATE TABLE Documents (
document_id INTEGER NOT NULL,
document_status_code CHAR(15) NOT NULL,
document_type_code CHAR(15) NOT NULL,
shipping_agent_code CHAR(15),
receipt_date DATETIME,
receipt_number VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (document_id),
FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code),
FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code),
FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code)
);
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (1, 'working', 'CD', 'UP', '2008-04-21 20:42:25', '19', 'z');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (2, 'done', 'Paper', 'US', '1974-05-08 00:00:46', '34', 'h');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (3, 'done', 'Paper', 'UP', '2014-12-25 17:22:44', '93', 'h');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (4, 'done', 'Paper', 'US', '1973-11-05 21:48:53', '80', 'q');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (7, 'working', 'CD', 'SH', '1982-09-27 14:52:15', '61', 'w');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (10, 'overdue', 'Paper', 'UP', '1976-09-15 19:24:17', '8', 'm');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (12, 'overdue', 'Hard Drive', 'US', '1996-05-31 06:51:58', '69', 'n');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (13, 'working', 'CD', 'UP', '2015-04-03 09:36:19', '79', 'y');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (14, 'working', 'CD', 'FE', '2017-07-02 17:39:09', '117', 'u');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (15, 'overdue', 'CD', 'UP', '1986-12-14 14:18:59', '37', 'r');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (17, 'done', 'Paper', 'FE', '1983-09-26 09:32:56', '55', 'p');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (20, 'working', 'Paper', 'UP', '1996-07-27 03:30:40', '189', 'x');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (23, 'working', 'Hard Drive', 'FE', '1999-04-17 14:19:32', '124', 'b');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (24, 'working', 'Hard Drive', 'FE', '2005-09-30 00:10:02', '114', 'j');
INSERT INTO Documents (`document_id`, `document_status_code`, `document_type_code`, `shipping_agent_code`, `receipt_date`, `receipt_number`, `other_details`) VALUES (25, 'overdue', 'Hard Drive', 'AL', '1985-11-05 17:59:34', '83', 'u');
CREATE TABLE Employees (
employee_id INTEGER NOT NULL,
role_code CHAR(15) NOT NULL,
employee_name VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (employee_id),
FOREIGN KEY (role_code) REFERENCES Roles (role_code)
);
INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (1, 'ED', 'Koby', 'h');
INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (2, 'ED', 'Kenyon', 'f');
INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (3, 'PR', 'Haley', 'b');
INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (5, 'PT', 'Clemens', 'b');
INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (7, 'PT', 'Jordyn', 'v');
INSERT INTO Employees (`employee_id`, `role_code`, `employee_name`, `other_details`) VALUES (8, 'MG', 'Erling', 'u');
CREATE TABLE Document_Drafts (
document_id INTEGER NOT NULL,
draft_number INTEGER NOT NULL,
draft_details VARCHAR(255),
PRIMARY KEY (document_id, draft_number),
FOREIGN KEY (document_id) REFERENCES Documents (document_id)
);
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 0, 'e');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (1, 2, 'k');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (2, 1, 'v');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (2, 8, 'v');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (4, 9, 'r');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (7, 10, 'm');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (10, 20, 'k');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (12, 11, 'b');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (12, 12, 'r');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (13, 4, 'w');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (13, 16, 'p');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (14, 14, 'x');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (17, 19, 'a');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (20, 17, 'l');
INSERT INTO Document_Drafts (`document_id`, `draft_number`, `draft_details`) VALUES (23, 9, 'r');
CREATE TABLE Draft_Copies (
document_id INTEGER NOT NULL,
draft_number INTEGER NOT NULL,
copy_number INTEGER NOT NULL,
PRIMARY KEY (document_id, draft_number, copy_number),
FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number)
);
INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 8, 5);
INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (4, 9, 6);
INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (23, 9, 15);
INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (10, 20, 10);
INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (2, 1, 4);
INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (1, 2, 5);
INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (20, 17, 15);
INSERT INTO Draft_Copies (`document_id`, `draft_number`, `copy_number`) VALUES (12, 12, 10);
CREATE TABLE Circulation_History (
document_id INTEGER NOT NULL,
draft_number INTEGER NOT NULL,
copy_number INTEGER NOT NULL,
employee_id INTEGER NOT NULL,
PRIMARY KEY (document_id, draft_number, copy_number, employee_id),
FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number),
FOREIGN KEY (employee_id) REFERENCES Employees (employee_id)
);
INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (20, 17, 15, 8);
INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (1, 2, 5, 1);
INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (2, 1, 4, 2);
INSERT INTO Circulation_History (`document_id`, `draft_number`, `copy_number`, `employee_id`) VALUES (10, 20, 10, 2);
CREATE TABLE Documents_Mailed (
document_id INTEGER NOT NULL,
mailed_to_address_id INTEGER NOT NULL,
mailing_date DATETIME,
PRIMARY KEY (document_id, mailed_to_address_id),
FOREIGN KEY (document_id) REFERENCES Documents (document_id),
FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id)
);
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (2, 8, '1977-04-01 17:03:50');
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (4, 3, '1992-11-07 15:03:41');
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (4, 9, '1973-02-21 10:17:01');
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (7, 5, '1979-09-21 10:30:52');
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (10, 3, '1993-05-24 22:13:48');
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (12, 0, '1999-05-22 23:21:07');
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (12, 7, '2007-01-01 22:32:11');
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (12, 8, '2007-03-20 05:22:01');
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (13, 4, '1991-05-27 14:17:37');
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (14, 5, '1986-05-16 06:25:33');
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (20, 2, '2010-11-04 04:00:16');
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (20, 7, '1982-01-14 05:50:54');
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (23, 8, '1971-11-03 12:32:14');
INSERT INTO Documents_Mailed (`document_id`, `mailed_to_address_id`, `mailing_date`) VALUES (24, 0, '2013-01-27 03:29:31');
|