mingusbabcock-composite_primary_keys 2.2.2 → 2.2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +156 -0
- data/Manifest.txt +122 -0
- data/README.txt +41 -0
- data/README_DB2.txt +33 -0
- data/Rakefile +65 -0
- data/init.rb +2 -0
- data/install.rb +30 -0
- data/lib/adapter_helper/base.rb +63 -0
- data/lib/adapter_helper/mysql.rb +13 -0
- data/lib/adapter_helper/oracle.rb +12 -0
- data/lib/adapter_helper/postgresql.rb +13 -0
- data/lib/adapter_helper/sqlite3.rb +13 -0
- data/lib/composite_primary_keys.rb +56 -0
- data/lib/composite_primary_keys/association_preload.rb +253 -0
- data/lib/composite_primary_keys/associations.rb +428 -0
- data/lib/composite_primary_keys/attribute_methods.rb +84 -0
- data/lib/composite_primary_keys/base.rb +341 -0
- data/lib/composite_primary_keys/calculations.rb +69 -0
- data/lib/composite_primary_keys/composite_arrays.rb +30 -0
- data/lib/composite_primary_keys/connection_adapters/ibm_db_adapter.rb +21 -0
- data/lib/composite_primary_keys/connection_adapters/oracle_adapter.rb +15 -0
- data/lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb +53 -0
- data/lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb +15 -0
- data/lib/composite_primary_keys/fixtures.rb +8 -0
- data/lib/composite_primary_keys/migration.rb +20 -0
- data/lib/composite_primary_keys/reflection.rb +19 -0
- data/lib/composite_primary_keys/version.rb +8 -0
- data/loader.rb +24 -0
- data/local/database_connections.rb.sample +10 -0
- data/local/paths.rb.sample +2 -0
- data/local/tasks.rb.sample +2 -0
- data/scripts/console.rb +48 -0
- data/scripts/txt2html +67 -0
- data/scripts/txt2js +59 -0
- data/tasks/activerecord_selection.rake +43 -0
- data/tasks/databases.rake +12 -0
- data/tasks/databases/mysql.rake +30 -0
- data/tasks/databases/oracle.rake +25 -0
- data/tasks/databases/postgresql.rake +26 -0
- data/tasks/databases/sqlite3.rake +28 -0
- data/tasks/deployment.rake +22 -0
- data/tasks/local_setup.rake +13 -0
- data/tasks/website.rake +18 -0
- data/test/README_tests.txt +67 -0
- data/test/abstract_unit.rb +94 -0
- data/test/connections/native_ibm_db/connection.rb +23 -0
- data/test/connections/native_mysql/connection.rb +13 -0
- data/test/connections/native_oracle/connection.rb +14 -0
- data/test/connections/native_postgresql/connection.rb +9 -0
- data/test/connections/native_sqlite/connection.rb +9 -0
- data/test/fixtures/article.rb +5 -0
- data/test/fixtures/articles.yml +6 -0
- data/test/fixtures/comment.rb +6 -0
- data/test/fixtures/comments.yml +16 -0
- data/test/fixtures/db_definitions/db2-create-tables.sql +113 -0
- data/test/fixtures/db_definitions/db2-drop-tables.sql +16 -0
- data/test/fixtures/db_definitions/mysql.sql +174 -0
- data/test/fixtures/db_definitions/oracle.drop.sql +39 -0
- data/test/fixtures/db_definitions/oracle.sql +188 -0
- data/test/fixtures/db_definitions/postgresql.sql +199 -0
- data/test/fixtures/db_definitions/sqlite.sql +160 -0
- data/test/fixtures/department.rb +5 -0
- data/test/fixtures/departments.yml +3 -0
- data/test/fixtures/employee.rb +4 -0
- data/test/fixtures/employees.yml +9 -0
- data/test/fixtures/group.rb +3 -0
- data/test/fixtures/groups.yml +3 -0
- data/test/fixtures/hack.rb +6 -0
- data/test/fixtures/hacks.yml +2 -0
- data/test/fixtures/membership.rb +7 -0
- data/test/fixtures/membership_status.rb +3 -0
- data/test/fixtures/membership_statuses.yml +10 -0
- data/test/fixtures/memberships.yml +6 -0
- data/test/fixtures/product.rb +7 -0
- data/test/fixtures/product_tariff.rb +5 -0
- data/test/fixtures/product_tariffs.yml +12 -0
- data/test/fixtures/products.yml +6 -0
- data/test/fixtures/reading.rb +4 -0
- data/test/fixtures/readings.yml +10 -0
- data/test/fixtures/reference_code.rb +7 -0
- data/test/fixtures/reference_codes.yml +28 -0
- data/test/fixtures/reference_type.rb +7 -0
- data/test/fixtures/reference_types.yml +9 -0
- data/test/fixtures/street.rb +3 -0
- data/test/fixtures/streets.yml +15 -0
- data/test/fixtures/suburb.rb +6 -0
- data/test/fixtures/suburbs.yml +9 -0
- data/test/fixtures/tariff.rb +6 -0
- data/test/fixtures/tariffs.yml +13 -0
- data/test/fixtures/user.rb +10 -0
- data/test/fixtures/users.yml +6 -0
- data/test/hash_tricks.rb +34 -0
- data/test/plugins/pagination.rb +405 -0
- data/test/plugins/pagination_helper.rb +135 -0
- data/test/test_associations.rb +160 -0
- data/test/test_attribute_methods.rb +22 -0
- data/test/test_attributes.rb +84 -0
- data/test/test_clone.rb +34 -0
- data/test/test_composite_arrays.rb +51 -0
- data/test/test_create.rb +68 -0
- data/test/test_delete.rb +96 -0
- data/test/test_dummy.rb +28 -0
- data/test/test_exists.rb +29 -0
- data/test/test_find.rb +73 -0
- data/test/test_ids.rb +97 -0
- data/test/test_miscellaneous.rb +39 -0
- data/test/test_pagination.rb +38 -0
- data/test/test_polymorphic.rb +31 -0
- data/test/test_santiago.rb +27 -0
- data/test/test_tutorial_examle.rb +26 -0
- data/test/test_update.rb +40 -0
- data/website/index.html +199 -0
- data/website/index.txt +159 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +126 -0
- data/website/template.js +3 -0
- data/website/template.rhtml +53 -0
- data/website/version-raw.js +3 -0
- data/website/version-raw.txt +2 -0
- data/website/version.js +4 -0
- data/website/version.txt +3 -0
- metadata +180 -18
@@ -0,0 +1,113 @@
|
|
1
|
+
CREATE TABLE reference_types (
|
2
|
+
reference_type_id integer NOT NULL generated by default as identity (start with 100, increment by 1, no cache),
|
3
|
+
type_label varchar(50) default NULL,
|
4
|
+
abbreviation varchar(50) default NULL,
|
5
|
+
description varchar(50) default NULL,
|
6
|
+
PRIMARY KEY (reference_type_id)
|
7
|
+
);
|
8
|
+
|
9
|
+
CREATE TABLE reference_codes (
|
10
|
+
reference_type_id integer,
|
11
|
+
reference_code integer NOT NULL,
|
12
|
+
code_label varchar(50) default NULL,
|
13
|
+
abbreviation varchar(50) default NULL,
|
14
|
+
description varchar(50) default NULL,
|
15
|
+
PRIMARY KEY (reference_type_id,reference_code)
|
16
|
+
);
|
17
|
+
|
18
|
+
CREATE TABLE products (
|
19
|
+
id integer NOT NULL,
|
20
|
+
name varchar(50) default NULL,
|
21
|
+
PRIMARY KEY (id)
|
22
|
+
);
|
23
|
+
|
24
|
+
CREATE TABLE tariffs (
|
25
|
+
tariff_id integer NOT NULL,
|
26
|
+
start_date date NOT NULL,
|
27
|
+
amount integer default NULL,
|
28
|
+
PRIMARY KEY (tariff_id,start_date)
|
29
|
+
);
|
30
|
+
|
31
|
+
CREATE TABLE product_tariffs (
|
32
|
+
product_id integer NOT NULL,
|
33
|
+
tariff_id integer NOT NULL,
|
34
|
+
tariff_start_date date NOT NULL,
|
35
|
+
PRIMARY KEY (product_id,tariff_id,tariff_start_date)
|
36
|
+
);
|
37
|
+
|
38
|
+
CREATE TABLE suburbs (
|
39
|
+
city_id integer NOT NULL,
|
40
|
+
suburb_id integer NOT NULL,
|
41
|
+
name varchar(50) NOT NULL,
|
42
|
+
PRIMARY KEY (city_id,suburb_id)
|
43
|
+
);
|
44
|
+
|
45
|
+
CREATE TABLE streets (
|
46
|
+
id integer NOT NULL ,
|
47
|
+
city_id integer NOT NULL,
|
48
|
+
suburb_id integer NOT NULL,
|
49
|
+
name varchar(50) NOT NULL,
|
50
|
+
PRIMARY KEY (id)
|
51
|
+
);
|
52
|
+
|
53
|
+
CREATE TABLE users (
|
54
|
+
id integer NOT NULL ,
|
55
|
+
name varchar(50) NOT NULL,
|
56
|
+
PRIMARY KEY (id)
|
57
|
+
);
|
58
|
+
|
59
|
+
CREATE TABLE articles (
|
60
|
+
id integer NOT NULL ,
|
61
|
+
name varchar(50) NOT NULL,
|
62
|
+
PRIMARY KEY (id)
|
63
|
+
);
|
64
|
+
|
65
|
+
CREATE TABLE readings (
|
66
|
+
id integer NOT NULL ,
|
67
|
+
user_id integer NOT NULL,
|
68
|
+
article_id integer NOT NULL,
|
69
|
+
rating integer NOT NULL,
|
70
|
+
PRIMARY KEY (id)
|
71
|
+
);
|
72
|
+
|
73
|
+
CREATE TABLE groups (
|
74
|
+
id integer NOT NULL ,
|
75
|
+
name varchar(50) NOT NULL,
|
76
|
+
PRIMARY KEY (id)
|
77
|
+
);
|
78
|
+
|
79
|
+
CREATE TABLE memberships (
|
80
|
+
user_id integer NOT NULL,
|
81
|
+
group_id integer NOT NULL,
|
82
|
+
PRIMARY KEY (user_id,group_id)
|
83
|
+
);
|
84
|
+
|
85
|
+
CREATE TABLE membership_statuses (
|
86
|
+
id integer NOT NULL ,
|
87
|
+
user_id integer NOT NULL,
|
88
|
+
group_id integer NOT NULL,
|
89
|
+
status varchar(50) NOT NULL,
|
90
|
+
PRIMARY KEY (id)
|
91
|
+
);
|
92
|
+
|
93
|
+
create table kitchen_sinks (
|
94
|
+
id_1 integer not null,
|
95
|
+
id_2 integer not null,
|
96
|
+
a_date date,
|
97
|
+
a_string varchar(100),
|
98
|
+
primary key (id_1, id_2)
|
99
|
+
);
|
100
|
+
|
101
|
+
create table restaurants (
|
102
|
+
franchise_id integer not null,
|
103
|
+
store_id integer not null,
|
104
|
+
name varchar(100),
|
105
|
+
primary key (franchise_id, store_id)
|
106
|
+
);
|
107
|
+
|
108
|
+
create table restaurants_suburbs (
|
109
|
+
franchise_id integer not null,
|
110
|
+
store_id integer not null,
|
111
|
+
city_id integer not null,
|
112
|
+
suburb_id integer not null
|
113
|
+
);
|
@@ -0,0 +1,16 @@
|
|
1
|
+
drop table MEMBERSHIPS;
|
2
|
+
drop table REFERENCE_CODES;
|
3
|
+
drop table TARIFFS;
|
4
|
+
drop table ARTICLES;
|
5
|
+
drop table GROUPS;
|
6
|
+
drop table MEMBERSHIP_STATUSES;
|
7
|
+
drop table READINGS;
|
8
|
+
drop table REFERENCE_TYPES;
|
9
|
+
drop table STREETS;
|
10
|
+
drop table PRODUCTS;
|
11
|
+
drop table USERS;
|
12
|
+
drop table SUBURBS;
|
13
|
+
drop table PRODUCT_TARIFFS;
|
14
|
+
drop table KITCHEN_SINK;
|
15
|
+
drop table RESTAURANTS;
|
16
|
+
drop table RESTAURANTS_SUBURBS;
|
@@ -0,0 +1,174 @@
|
|
1
|
+
create table reference_types (
|
2
|
+
reference_type_id int(11) not null auto_increment,
|
3
|
+
type_label varchar(50) default null,
|
4
|
+
abbreviation varchar(50) default null,
|
5
|
+
description varchar(50) default null,
|
6
|
+
primary key (reference_type_id)
|
7
|
+
) type=InnoDB;
|
8
|
+
|
9
|
+
create table reference_codes (
|
10
|
+
reference_type_id int(11),
|
11
|
+
reference_code int(11) not null,
|
12
|
+
code_label varchar(50) default null,
|
13
|
+
abbreviation varchar(50) default null,
|
14
|
+
description varchar(50) default null,
|
15
|
+
primary key (reference_type_id, reference_code)
|
16
|
+
) type=InnoDB;
|
17
|
+
|
18
|
+
create table products (
|
19
|
+
id int(11) not null auto_increment,
|
20
|
+
name varchar(50) default null,
|
21
|
+
primary key (id)
|
22
|
+
) type=InnoDB;
|
23
|
+
|
24
|
+
create table tariffs (
|
25
|
+
tariff_id int(11) not null,
|
26
|
+
start_date date not null,
|
27
|
+
amount integer(11) default null,
|
28
|
+
primary key (tariff_id, start_date)
|
29
|
+
) type=InnoDB;
|
30
|
+
|
31
|
+
create table product_tariffs (
|
32
|
+
product_id int(11) not null,
|
33
|
+
tariff_id int(11) not null,
|
34
|
+
tariff_start_date date not null,
|
35
|
+
primary key (product_id, tariff_id, tariff_start_date)
|
36
|
+
) type=InnoDB;
|
37
|
+
|
38
|
+
create table suburbs (
|
39
|
+
city_id int(11) not null,
|
40
|
+
suburb_id int(11) not null,
|
41
|
+
name varchar(50) not null,
|
42
|
+
primary key (city_id, suburb_id)
|
43
|
+
) type=InnoDB;
|
44
|
+
|
45
|
+
create table streets (
|
46
|
+
id int(11) not null auto_increment,
|
47
|
+
city_id int(11) not null,
|
48
|
+
suburb_id int(11) not null,
|
49
|
+
name varchar(50) not null,
|
50
|
+
primary key (id)
|
51
|
+
) type=InnoDB;
|
52
|
+
|
53
|
+
create table users (
|
54
|
+
id int(11) not null auto_increment,
|
55
|
+
name varchar(50) not null,
|
56
|
+
primary key (id)
|
57
|
+
) type=InnoDB;
|
58
|
+
|
59
|
+
create table articles (
|
60
|
+
id int(11) not null auto_increment,
|
61
|
+
name varchar(50) not null,
|
62
|
+
primary key (id)
|
63
|
+
) type=InnoDB;
|
64
|
+
|
65
|
+
create table readings (
|
66
|
+
id int(11) not null auto_increment,
|
67
|
+
user_id int(11) not null,
|
68
|
+
article_id int(11) not null,
|
69
|
+
rating int(11) not null,
|
70
|
+
primary key (id)
|
71
|
+
) type=InnoDB;
|
72
|
+
|
73
|
+
create table groups (
|
74
|
+
id int(11) not null auto_increment,
|
75
|
+
name varchar(50) not null,
|
76
|
+
primary key (id)
|
77
|
+
) type=InnoDB;
|
78
|
+
|
79
|
+
create table memberships (
|
80
|
+
user_id int(11) not null,
|
81
|
+
group_id int(11) not null,
|
82
|
+
primary key (user_id,group_id)
|
83
|
+
) type=InnoDB;
|
84
|
+
|
85
|
+
create table membership_statuses (
|
86
|
+
id int(11) not null auto_increment,
|
87
|
+
user_id int(11) not null,
|
88
|
+
group_id int(11) not null,
|
89
|
+
status varchar(50) not null,
|
90
|
+
primary key (id)
|
91
|
+
) type=InnoDB;
|
92
|
+
|
93
|
+
create table departments (
|
94
|
+
department_id int(11) not null,
|
95
|
+
location_id int(11) not null,
|
96
|
+
primary key (department_id, location_id)
|
97
|
+
) type=InnoDB;
|
98
|
+
|
99
|
+
create table employees (
|
100
|
+
id int(11) not null auto_increment,
|
101
|
+
department_id int(11) default null,
|
102
|
+
location_id int(11) default null,
|
103
|
+
primary key (id)
|
104
|
+
) type=InnoDB;
|
105
|
+
|
106
|
+
create table comments (
|
107
|
+
id int(11) not null auto_increment,
|
108
|
+
person_id varchar(100) default null,
|
109
|
+
person_type varchar(100) default null,
|
110
|
+
hack_id varchar(100) default null,
|
111
|
+
primary key (id)
|
112
|
+
) type=InnoDB;
|
113
|
+
|
114
|
+
create table hacks (
|
115
|
+
name varchar(50) not null,
|
116
|
+
primary key (name)
|
117
|
+
) type=InnoDB;
|
118
|
+
|
119
|
+
create table kitchen_sinks (
|
120
|
+
id_1 int(11) not null,
|
121
|
+
id_2 int(11) not null,
|
122
|
+
a_date date,
|
123
|
+
a_string varchar(100),
|
124
|
+
primary key (id_1, id_2)
|
125
|
+
) type=InnoDB;
|
126
|
+
|
127
|
+
create table restaurants (
|
128
|
+
franchise_id int(11) not null,
|
129
|
+
store_id int(11) not null,
|
130
|
+
name varchar(100),
|
131
|
+
primary key (franchise_id, store_id)
|
132
|
+
) type=InnoDB;
|
133
|
+
|
134
|
+
create table restaurants_suburbs (
|
135
|
+
franchise_id int(11) not null,
|
136
|
+
store_id int(11) not null,
|
137
|
+
city_id int(11) not null,
|
138
|
+
suburb_id int(11) not null
|
139
|
+
) type=InnoDB;
|
140
|
+
|
141
|
+
create table dorms (
|
142
|
+
id int(11) not null auto_increment,
|
143
|
+
primary key(id)
|
144
|
+
) type=InnoDB;
|
145
|
+
|
146
|
+
create table rooms (
|
147
|
+
dorm_id int(11) not null,
|
148
|
+
room_id int(11) not null,
|
149
|
+
primary key (dorm_id, room_id)
|
150
|
+
) type=InnoDB;
|
151
|
+
|
152
|
+
create table room_attributes (
|
153
|
+
id int(11) not null auto_increment,
|
154
|
+
name varchar(50),
|
155
|
+
primary key(id)
|
156
|
+
) type=InnoDB;
|
157
|
+
|
158
|
+
create table room_attribute_assignments (
|
159
|
+
dorm_id int(11) not null,
|
160
|
+
room_id int(11) not null,
|
161
|
+
room_attribute_id int(11) not null
|
162
|
+
) type=InnoDB;
|
163
|
+
|
164
|
+
create table students (
|
165
|
+
id int(11) not null auto_increment,
|
166
|
+
primary key(id)
|
167
|
+
) type=InnoDB;
|
168
|
+
|
169
|
+
create table room_assignments (
|
170
|
+
student_id int(11) not null,
|
171
|
+
dorm_id int(11) not null,
|
172
|
+
room_id int(11) not null
|
173
|
+
) type=InnoDB;
|
174
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
drop table reference_types;
|
2
|
+
drop sequence reference_types_seq;
|
3
|
+
drop table reference_codes;
|
4
|
+
drop table products;
|
5
|
+
drop sequence products_seq;
|
6
|
+
drop table tariffs;
|
7
|
+
drop table product_tariffs;
|
8
|
+
drop table suburbs;
|
9
|
+
drop table streets;
|
10
|
+
drop sequence streets_seq;
|
11
|
+
drop table users;
|
12
|
+
drop sequence users_seq;
|
13
|
+
drop table articles;
|
14
|
+
drop sequence articles_seq;
|
15
|
+
drop table readings;
|
16
|
+
drop sequence readings_seq;
|
17
|
+
drop table groups;
|
18
|
+
drop sequence groups_seq;
|
19
|
+
drop table memberships;
|
20
|
+
drop table membership_statuses;
|
21
|
+
drop sequence membership_statuses_seq;
|
22
|
+
drop table departments;
|
23
|
+
drop table employees;
|
24
|
+
drop sequence employees_seq;
|
25
|
+
drop table comments;
|
26
|
+
drop sequence comments_seq;
|
27
|
+
drop table hacks;
|
28
|
+
drop table kitchen_sinks;
|
29
|
+
drop table restaurants;
|
30
|
+
drop table restaurants_suburbs;
|
31
|
+
drop table dorms;
|
32
|
+
drop sequence dorms_seq;
|
33
|
+
drop table rooms;
|
34
|
+
drop table room_attributes;
|
35
|
+
drop sequence room_attributes_seq;
|
36
|
+
drop table room_attribute_assignments;
|
37
|
+
drop table room_assignments;
|
38
|
+
drop table students;
|
39
|
+
drop sequence students_seq;
|
@@ -0,0 +1,188 @@
|
|
1
|
+
create sequence reference_types_seq start with 1000;
|
2
|
+
|
3
|
+
create table reference_types (
|
4
|
+
reference_type_id number(11) primary key,
|
5
|
+
type_label varchar2(50) default null,
|
6
|
+
abbreviation varchar2(50) default null,
|
7
|
+
description varchar2(50) default null
|
8
|
+
);
|
9
|
+
|
10
|
+
create table reference_codes (
|
11
|
+
reference_type_id number(11),
|
12
|
+
reference_code number(11),
|
13
|
+
code_label varchar2(50) default null,
|
14
|
+
abbreviation varchar2(50) default null,
|
15
|
+
description varchar2(50) default null
|
16
|
+
);
|
17
|
+
|
18
|
+
create sequence products_seq start with 1000;
|
19
|
+
|
20
|
+
create table products (
|
21
|
+
id number(11) primary key,
|
22
|
+
name varchar2(50) default null
|
23
|
+
);
|
24
|
+
|
25
|
+
create table tariffs (
|
26
|
+
tariff_id number(11),
|
27
|
+
start_date date,
|
28
|
+
amount number(11) default null,
|
29
|
+
constraint tariffs_pk primary key (tariff_id, start_date)
|
30
|
+
);
|
31
|
+
|
32
|
+
create table product_tariffs (
|
33
|
+
product_id number(11),
|
34
|
+
tariff_id number(11),
|
35
|
+
tariff_start_date date,
|
36
|
+
constraint product_tariffs_pk primary key (product_id, tariff_id, tariff_start_date)
|
37
|
+
);
|
38
|
+
|
39
|
+
create table suburbs (
|
40
|
+
city_id number(11),
|
41
|
+
suburb_id number(11),
|
42
|
+
name varchar2(50) not null,
|
43
|
+
constraint suburbs_pk primary key (city_id, suburb_id)
|
44
|
+
);
|
45
|
+
|
46
|
+
create sequence streets_seq start with 1000;
|
47
|
+
|
48
|
+
create table streets (
|
49
|
+
id number(11) primary key,
|
50
|
+
city_id number(11) not null,
|
51
|
+
suburb_id number(11) not null,
|
52
|
+
name varchar2(50) not null
|
53
|
+
);
|
54
|
+
|
55
|
+
create sequence users_seq start with 1000;
|
56
|
+
|
57
|
+
create table users (
|
58
|
+
id number(11) primary key,
|
59
|
+
name varchar2(50) not null
|
60
|
+
);
|
61
|
+
|
62
|
+
create sequence articles_seq start with 1000;
|
63
|
+
|
64
|
+
create table articles (
|
65
|
+
id number(11) primary key,
|
66
|
+
name varchar2(50) not null
|
67
|
+
);
|
68
|
+
|
69
|
+
create sequence readings_seq start with 1000;
|
70
|
+
|
71
|
+
create table readings (
|
72
|
+
id number(11) primary key,
|
73
|
+
user_id number(11) not null,
|
74
|
+
article_id number(11) not null,
|
75
|
+
rating number(11) not null
|
76
|
+
);
|
77
|
+
|
78
|
+
create sequence groups_seq start with 1000;
|
79
|
+
|
80
|
+
create table groups (
|
81
|
+
id number(11) primary key,
|
82
|
+
name varchar2(50) not null
|
83
|
+
);
|
84
|
+
|
85
|
+
create table memberships (
|
86
|
+
user_id number(11) not null,
|
87
|
+
group_id number(11) not null,
|
88
|
+
constraint memberships_pk primary key (user_id, group_id)
|
89
|
+
);
|
90
|
+
|
91
|
+
create sequence membership_statuses_seq start with 1000;
|
92
|
+
|
93
|
+
create table membership_statuses (
|
94
|
+
id number(11) primary key,
|
95
|
+
user_id number(11) not null,
|
96
|
+
group_id number(11) not null,
|
97
|
+
status varchar2(50) not null
|
98
|
+
);
|
99
|
+
|
100
|
+
create table departments (
|
101
|
+
department_id number(11) not null,
|
102
|
+
location_id number(11) not null,
|
103
|
+
constraint departments_pk primary key (department_id, location_id)
|
104
|
+
);
|
105
|
+
|
106
|
+
create sequence employees_seq start with 1000;
|
107
|
+
|
108
|
+
create table employees (
|
109
|
+
id number(11) not null primary key,
|
110
|
+
department_id number(11) default null,
|
111
|
+
location_id number(11) default null
|
112
|
+
);
|
113
|
+
|
114
|
+
create sequence comments_seq start with 1000;
|
115
|
+
|
116
|
+
create table comments (
|
117
|
+
id number(11) not null primary key,
|
118
|
+
person_id varchar(100) default null,
|
119
|
+
person_type varchar(100) default null,
|
120
|
+
hack_id varchar(100) default null
|
121
|
+
);
|
122
|
+
|
123
|
+
create table hacks (
|
124
|
+
name varchar(50) not null primary key
|
125
|
+
);
|
126
|
+
|
127
|
+
create table kitchen_sinks (
|
128
|
+
id_1 number(11) not null,
|
129
|
+
id_2 number(11) not null,
|
130
|
+
a_date date,
|
131
|
+
a_string varchar(100),
|
132
|
+
constraint kitchen_sinks_pk primary key (id_1, id_2)
|
133
|
+
);
|
134
|
+
|
135
|
+
create table restaurants (
|
136
|
+
franchise_id number(11) not null,
|
137
|
+
store_id number(11) not null,
|
138
|
+
name varchar(100),
|
139
|
+
constraint restaurants_pk primary key (franchise_id, store_id)
|
140
|
+
);
|
141
|
+
|
142
|
+
create table restaurants_suburbs (
|
143
|
+
franchise_id number(11) not null,
|
144
|
+
store_id number(11) not null,
|
145
|
+
city_id number(11) not null,
|
146
|
+
suburb_id number(11) not null
|
147
|
+
);
|
148
|
+
|
149
|
+
create sequence dorms_seq start with 1000;
|
150
|
+
|
151
|
+
create table dorms (
|
152
|
+
id number(11) not null,
|
153
|
+
constraint dorms_pk primary key (id)
|
154
|
+
);
|
155
|
+
|
156
|
+
create table rooms (
|
157
|
+
dorm_id number(11) not null,
|
158
|
+
room_id number(11) not null,
|
159
|
+
constraint rooms_pk primary key (dorm_id, room_id)
|
160
|
+
);
|
161
|
+
|
162
|
+
create sequence room_attributes_seq start with 1000;
|
163
|
+
|
164
|
+
create table room_attributes (
|
165
|
+
id number(11) not null,
|
166
|
+
name varchar(50),
|
167
|
+
constraint room_attributes_pk primary key (id)
|
168
|
+
);
|
169
|
+
|
170
|
+
create table room_attribute_assignments (
|
171
|
+
dorm_id number(11) not null,
|
172
|
+
room_id number(11) not null,
|
173
|
+
room_attribute_id number(11) not null
|
174
|
+
);
|
175
|
+
|
176
|
+
create sequence students_seq start with 1000;
|
177
|
+
|
178
|
+
create table students (
|
179
|
+
id number(11) not null,
|
180
|
+
constraint students_pk primary key (id)
|
181
|
+
);
|
182
|
+
|
183
|
+
create table room_assignments (
|
184
|
+
student_id number(11) not null,
|
185
|
+
dorm_id number(11) not null,
|
186
|
+
room_id number(11) not null
|
187
|
+
);
|
188
|
+
|