forked from bfjf/gnoto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_mouseDB.sql
executable file
·114 lines (100 loc) · 3.35 KB
/
create_mouseDB.sql
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
/* CREATE_MOUSEDB.SQL */
/* Description: A schema for the database holding mouse breeding data in a gnotobiotic facility
/* Authors: faith
/* Date: Thu Oct 20 14:36:25 CDT 2011
/* CREATE DATABASE MOUSEDB
/*
** add administrator to database (ID)
** add administrator table
** add cylinder table (cylinder, vendor, start-date)
** add cylinder_addition table (cylinderID, date, liquid/dry)
** add notes (ID (cage, mouse, isolator), type ("cage", "mouse", "isolator"), date, note (text))
** remove cage type
** what to do with isolator size (put 2ft, 3ft, 4ft, 6ft?)
*** replace with isolator description?
* place to remove cages; where? (in isolator?); only allow removal of empty cages; warn that cages will be renumbered!!!
*/
/*--------------------------------------------------------------------------
MOUSE TABLE
--------------------------------------------------------------------------*/
drop table if exists mouse;
create table mouse
(mouse_id integer PRIMARY KEY,
sex text, /*('male', 'female','?'), */
birth_date integer NOT NULL,
wean_date integer,
death_date integer,
death_type text, /*ENUM('sacrifice', 'parental neglect','unknown'), */
mouse_type text, /*('breeder', 'experimental'), */
strain text,
genotype text, /*varchar(255), */
cage_id integer,
FOREIGN KEY(cage_id) REFERENCES cage(cage_id)
);
create index mouse_a ON mouse(birth_date);
create index mouse_b ON mouse(cage_id);
drop table if exists cage;
create table cage
(cage_id integer primary key,
isolator_id integer,
start_date integer,
end_date integer,
FOREIGN KEY(isolator_id) REFERENCES isolator(isolator_id)
);
create index cage_a ON cage(isolator_id);
drop table if exists isolator;
create table isolator
(isolator_id integer primary key,
isolator_description text, /* vendor and size */
administrator text, /* vendor and size */
start_date integer,
end_date integer
);
drop table if exists note;
create table note
(id integer,
id_type text,
note text,
note_date integer
);
drop table if exists strain;
create table strain
(strain_name text NOT NULL UNIQUE/* small, medium, large */
);
insert into strain VALUES('C57BL/6J');
insert into strain VALUES('Swiss Webster');
drop table if exists genotype;
create table genotype
(genotype_name text NOT NULL UNIQUE /* small, medium, large */
);
insert into genotype VALUES('WT');
insert into genotype VALUES('unknown');
drop table if exists assignable;
create table assignable
(
assign text NOT NULL UNIQUE, /* small, medium, large */
description text /* small, medium, large */
);
insert into assignable VALUES('SL', 'Sergio Lira');
insert into assignable VALUES('JJF', 'Jeremiah Faith');
insert into assignable VALUES('MM', 'Miriam Merad');
/*drop table if exists mouse_to_cage;
create table mouse_to_cage
(mouse_id integer,
cage_id integer,
start_date integer,
FOREIGN KEY(mouse_id) REFERENCES mouse(mouse_id),
FOREIGN KEY(cage_id) REFERENCES cage(cage_id)
);
create index mouse_to_cage_a ON mouse_to_cage(mouse_id);
create index mouse_to_cage_b ON mouse_to_cage(cage_id);
*/
drop table if exists mouse_to_parent;
create table mouse_to_parent
(mouse_id integer NOT NULL,
parent_id integer NOT NULL,
FOREIGN KEY(mouse_id) REFERENCES mouse(mouse_id),
FOREIGN KEY(parent_id) REFERENCES mouse(mouse_id)
);
create index mouse_to_parent_a ON mouse_to_parent(mouse_id);
create index mouse_to_parent_b ON mouse_to_parent(parent_id);