globe-composite_primary_keys 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +203 -0
- data/Manifest.txt +121 -0
- data/README.txt +41 -0
- data/README_DB2.txt +33 -0
- data/Rakefile +30 -0
- data/composite_primary_keys.gemspec +17 -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/oracle_enhanced.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 +63 -0
- data/lib/composite_primary_keys/association_preload.rb +162 -0
- data/lib/composite_primary_keys/associations.rb +159 -0
- data/lib/composite_primary_keys/attribute_methods.rb +84 -0
- data/lib/composite_primary_keys/base.rb +200 -0
- data/lib/composite_primary_keys/composite_arrays.rb +29 -0
- data/lib/composite_primary_keys/connection_adapters/abstract_adapter.rb +9 -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/oracle_enhanced_adapter.rb +17 -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/finder_methods.rb +68 -0
- data/lib/composite_primary_keys/fixtures.rb +8 -0
- data/lib/composite_primary_keys/read.rb +25 -0
- data/lib/composite_primary_keys/reflection.rb +39 -0
- data/lib/composite_primary_keys/relation.rb +31 -0
- data/lib/composite_primary_keys/through_association_scope.rb +212 -0
- data/lib/composite_primary_keys/validations/uniqueness.rb +118 -0
- data/lib/composite_primary_keys/version.rb +9 -0
- data/loader.rb +24 -0
- data/local/database_connections.rb.sample +12 -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 +25 -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 +103 -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_oracle_enhanced/connection.rb +20 -0
- data/test/connections/native_postgresql/connection.rb +8 -0
- data/test/connections/native_sqlite/connection.rb +9 -0
- data/test/fixtures/article.rb +5 -0
- data/test/fixtures/article_group.rb +4 -0
- data/test/fixtures/article_groups.yml +7 -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 +181 -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 +206 -0
- data/test/fixtures/db_definitions/sqlite.sql +166 -0
- data/test/fixtures/department.rb +5 -0
- data/test/fixtures/departments.yml +3 -0
- data/test/fixtures/dorm.rb +3 -0
- data/test/fixtures/dorms.yml +2 -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/kitchen_sink.rb +3 -0
- data/test/fixtures/kitchen_sinks.yml +5 -0
- data/test/fixtures/membership.rb +10 -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/restaurant.rb +6 -0
- data/test/fixtures/restaurants.yml +5 -0
- data/test/fixtures/restaurants_suburbs.yml +11 -0
- data/test/fixtures/room.rb +10 -0
- data/test/fixtures/room_assignment.rb +4 -0
- data/test/fixtures/room_assignments.yml +4 -0
- data/test/fixtures/room_attribute.rb +3 -0
- data/test/fixtures/room_attribute_assignment.rb +5 -0
- data/test/fixtures/room_attribute_assignments.yml +4 -0
- data/test/fixtures/room_attributes.yml +3 -0
- data/test/fixtures/rooms.yml +3 -0
- data/test/fixtures/seat.rb +5 -0
- data/test/fixtures/seats.yml +4 -0
- data/test/fixtures/street.rb +3 -0
- data/test/fixtures/streets.yml +15 -0
- data/test/fixtures/student.rb +4 -0
- data/test/fixtures/students.yml +2 -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 +178 -0
- data/test/test_attribute_methods.rb +22 -0
- data/test/test_attributes.rb +80 -0
- data/test/test_clone.rb +34 -0
- data/test/test_composite_arrays.rb +32 -0
- data/test/test_create.rb +68 -0
- data/test/test_delete.rb +83 -0
- data/test/test_exists.rb +25 -0
- data/test/test_find.rb +73 -0
- data/test/test_ids.rb +90 -0
- data/test/test_miscellaneous.rb +39 -0
- data/test/test_pagination.rb +38 -0
- data/test/test_polymorphic.rb +32 -0
- data/test/test_santiago.rb +27 -0
- data/test/test_suite.rb +19 -0
- data/test/test_tutorial_example.rb +26 -0
- data/test/test_update.rb +40 -0
- data/test/test_validations.rb +11 -0
- data/website/index.html +195 -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 +339 -0
@@ -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,181 @@
|
|
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
|
+
|
175
|
+
create table seats (
|
176
|
+
flight_number int(11) not null,
|
177
|
+
seat int(11) not null,
|
178
|
+
customer int,
|
179
|
+
primary key (flight_number, seat)
|
180
|
+
) type=InnoDB;
|
181
|
+
|
@@ -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
|
+
|
@@ -0,0 +1,206 @@
|
|
1
|
+
create sequence public.reference_types_seq start 1000;
|
2
|
+
|
3
|
+
create table reference_types (
|
4
|
+
reference_type_id int default nextval('public.reference_types_seq'),
|
5
|
+
type_label varchar(50) default null,
|
6
|
+
abbreviation varchar(50) default null,
|
7
|
+
description varchar(50) default null,
|
8
|
+
primary key (reference_type_id)
|
9
|
+
);
|
10
|
+
|
11
|
+
create table reference_codes (
|
12
|
+
reference_type_id int,
|
13
|
+
reference_code int not null,
|
14
|
+
code_label varchar(50) default null,
|
15
|
+
abbreviation varchar(50) default null,
|
16
|
+
description varchar(50) default null
|
17
|
+
);
|
18
|
+
|
19
|
+
create sequence public.products_seq start 1000;
|
20
|
+
|
21
|
+
create table products (
|
22
|
+
id int not null default nextval('public.products_seq'),
|
23
|
+
name varchar(50) default null,
|
24
|
+
primary key (id)
|
25
|
+
);
|
26
|
+
|
27
|
+
create table tariffs (
|
28
|
+
tariff_id int not null,
|
29
|
+
start_date date not null,
|
30
|
+
amount int default null,
|
31
|
+
primary key (tariff_id, start_date)
|
32
|
+
);
|
33
|
+
|
34
|
+
create table product_tariffs (
|
35
|
+
product_id int not null,
|
36
|
+
tariff_id int not null,
|
37
|
+
tariff_start_date date not null,
|
38
|
+
primary key (product_id, tariff_id, tariff_start_date)
|
39
|
+
);
|
40
|
+
|
41
|
+
create table suburbs (
|
42
|
+
city_id int not null,
|
43
|
+
suburb_id int not null,
|
44
|
+
name varchar(50) not null,
|
45
|
+
primary key (city_id, suburb_id)
|
46
|
+
);
|
47
|
+
|
48
|
+
create sequence public.streets_seq start 1000;
|
49
|
+
|
50
|
+
create table streets (
|
51
|
+
id int not null default nextval('public.streets_seq'),
|
52
|
+
city_id int not null,
|
53
|
+
suburb_id int not null,
|
54
|
+
name varchar(50) not null,
|
55
|
+
primary key (id)
|
56
|
+
);
|
57
|
+
|
58
|
+
create sequence public.users_seq start 1000;
|
59
|
+
|
60
|
+
create table users (
|
61
|
+
id int not null default nextval('public.users_seq'),
|
62
|
+
name varchar(50) not null,
|
63
|
+
primary key (id)
|
64
|
+
);
|
65
|
+
|
66
|
+
create sequence public.articles_seq start 1000;
|
67
|
+
|
68
|
+
create table articles (
|
69
|
+
id int not null default nextval('public.articles_seq'),
|
70
|
+
name varchar(50) not null,
|
71
|
+
primary key (id)
|
72
|
+
);
|
73
|
+
|
74
|
+
create sequence public.readings_seq start 1000;
|
75
|
+
|
76
|
+
create table readings (
|
77
|
+
id int not null default nextval('public.readings_seq'),
|
78
|
+
user_id int not null,
|
79
|
+
article_id int not null,
|
80
|
+
rating int not null,
|
81
|
+
primary key (id)
|
82
|
+
);
|
83
|
+
|
84
|
+
create sequence public.groups_seq start 1000;
|
85
|
+
|
86
|
+
create table groups (
|
87
|
+
id int not null default nextval('public.groups_seq'),
|
88
|
+
name varchar(50) not null,
|
89
|
+
primary key (id)
|
90
|
+
);
|
91
|
+
|
92
|
+
create table memberships (
|
93
|
+
user_id int not null,
|
94
|
+
group_id int not null,
|
95
|
+
primary key (user_id, group_id)
|
96
|
+
);
|
97
|
+
|
98
|
+
create sequence public.membership_statuses_seq start 1000;
|
99
|
+
|
100
|
+
create table membership_statuses (
|
101
|
+
id int not null default nextval('public.membership_statuses_seq'),
|
102
|
+
user_id int not null,
|
103
|
+
group_id int not null,
|
104
|
+
status varchar(50) not null,
|
105
|
+
primary key (id)
|
106
|
+
);
|
107
|
+
|
108
|
+
create table departments (
|
109
|
+
department_id int not null,
|
110
|
+
location_id int not null,
|
111
|
+
primary key (department_id, location_id)
|
112
|
+
);
|
113
|
+
|
114
|
+
create sequence public.employees_seq start 1000;
|
115
|
+
|
116
|
+
create table employees (
|
117
|
+
id int not null default nextval('public.employees_seq'),
|
118
|
+
department_id int default null,
|
119
|
+
location_id int default null,
|
120
|
+
primary key (id)
|
121
|
+
);
|
122
|
+
|
123
|
+
create sequence public.comments_seq start 1000;
|
124
|
+
|
125
|
+
create table comments (
|
126
|
+
id int not null default nextval('public.comments_seq'),
|
127
|
+
person_id varchar(100) default null,
|
128
|
+
person_type varchar(100) default null,
|
129
|
+
hack_id varchar(100) default null,
|
130
|
+
primary key (id)
|
131
|
+
);
|
132
|
+
|
133
|
+
create table hacks (
|
134
|
+
name varchar(50) not null,
|
135
|
+
primary key (name)
|
136
|
+
);
|
137
|
+
|
138
|
+
create table kitchen_sinks (
|
139
|
+
id_1 int not null,
|
140
|
+
id_2 int not null,
|
141
|
+
a_date date,
|
142
|
+
a_string varchar(100),
|
143
|
+
primary key (id_1, id_2)
|
144
|
+
);
|
145
|
+
|
146
|
+
create table restaurants (
|
147
|
+
franchise_id int not null,
|
148
|
+
store_id int not null,
|
149
|
+
name varchar(100),
|
150
|
+
primary key (franchise_id, store_id)
|
151
|
+
);
|
152
|
+
|
153
|
+
create table restaurants_suburbs (
|
154
|
+
franchise_id int not null,
|
155
|
+
store_id int not null,
|
156
|
+
city_id int not null,
|
157
|
+
suburb_id int not null
|
158
|
+
);
|
159
|
+
|
160
|
+
create sequence public.dorms_seq start 1000;
|
161
|
+
|
162
|
+
create table dorms (
|
163
|
+
id int not null default nextval('public.dorms_seq'),
|
164
|
+
primary key (id)
|
165
|
+
);
|
166
|
+
|
167
|
+
create table rooms (
|
168
|
+
dorm_id int not null,
|
169
|
+
room_id int not null,
|
170
|
+
primary key (dorm_id, room_id)
|
171
|
+
);
|
172
|
+
|
173
|
+
create sequence public.room_attributes_seq start 1000;
|
174
|
+
|
175
|
+
create table room_attributes (
|
176
|
+
id int not null default nextval('public.room_attributes_seq'),
|
177
|
+
name varchar(50),
|
178
|
+
primary key (id)
|
179
|
+
);
|
180
|
+
|
181
|
+
create table room_attribute_assignments (
|
182
|
+
dorm_id int not null,
|
183
|
+
room_id int not null,
|
184
|
+
room_attribute_id int not null
|
185
|
+
);
|
186
|
+
|
187
|
+
create sequence public.students_seq start 1000;
|
188
|
+
|
189
|
+
create table students (
|
190
|
+
id int not null default nextval('public.students_seq'),
|
191
|
+
primary key (id)
|
192
|
+
);
|
193
|
+
|
194
|
+
create table room_assignments (
|
195
|
+
student_id int not null,
|
196
|
+
dorm_id int not null,
|
197
|
+
room_id int not null
|
198
|
+
);
|
199
|
+
|
200
|
+
create table seats (
|
201
|
+
flight_number int not null,
|
202
|
+
seat int not null,
|
203
|
+
customer int,
|
204
|
+
primary key (flight_number, seat)
|
205
|
+
);
|
206
|
+
|