-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_db.sql
More file actions
48 lines (43 loc) · 1.13 KB
/
create_db.sql
File metadata and controls
48 lines (43 loc) · 1.13 KB
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
USE cheminventory;
CREATE TABLE location (
location_id int NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL UNIQUE,
PRIMARY KEY (location_id)
);
CREATE TABLE supplier (
supplier_id int NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL UNIQUE,
PRIMARY KEY (supplier_id)
);
CREATE TABLE compound (
compound_id int NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
cas_no varchar(255),
molweight int,
formula varchar(255),
idcode varchar(255),
idcoords varchar(255),
fragfp varchar(255),
skelspheres varchar(1023),
PRIMARY KEY (compound_id)
);
CREATE TABLE bottle (
bottle_id int NOT NULL AUTO_INCREMENT,
compound_id int NOT NULL,
location_id int NOT NULL,
supplier_id int NOT NULL,
barcode varchar(255) NOT NULL UNIQUE,
catalog_no varchar(255),
amount_unit varchar(16),
initial_amount float NOT NULL,
current_amount float NOT NULL,
purity float,
density float,
tara float,
reg_date date,
comment varchar(255),
PRIMARY KEY (bottle_id),
FOREIGN KEY (compound_id) REFERENCES compound(compound_id),
FOREIGN KEY (location_id) REFERENCES location(location_id),
FOREIGN KEY (supplier_id) REFERENCES supplier(supplier_id)
);