1 create sequence public.reference_types_seq start 1000;
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)
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
19 create sequence public.products_seq start 1000;
21 create table products (
22 id int not null default nextval('public.products_seq'),
23 name varchar(50) default null,
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)
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)
41 create table suburbs (
43 suburb_id int not null,
44 name varchar(50) not null,
45 primary key (city_id, suburb_id)
48 create sequence public.streets_seq start 1000;
50 create table streets (
51 id int not null default nextval('public.streets_seq'),
53 suburb_id int not null,
54 name varchar(50) not null,
58 create sequence public.users_seq start 1000;
61 id int not null default nextval('public.users_seq'),
62 name varchar(50) not null,
66 create sequence public.articles_seq start 1000;
68 create table articles (
69 id int not null default nextval('public.articles_seq'),
70 name varchar(50) not null,
74 create sequence public.readings_seq start 1000;
76 create table readings (
77 id int not null default nextval('public.readings_seq'),
79 article_id int not null,
84 create sequence public.groups_seq start 1000;
87 id int not null default nextval('public.groups_seq'),
88 name varchar(50) not null,
92 create table memberships (
94 group_id int not null,
95 primary key (user_id, group_id)
98 create sequence public.membership_statuses_seq start 1000;
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,
108 create table departments (
109 department_id int not null,
110 location_id int not null,
111 primary key (department_id, location_id)
114 create sequence public.employees_seq start 1000;
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,
123 create sequence public.comments_seq start 1000;
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,
134 name varchar(50) not null,
138 create table kitchen_sinks (
142 a_string varchar(100),
143 primary key (id_1, id_2)
146 create table restaurants (
147 franchise_id int not null,
148 store_id int not null,
150 primary key (franchise_id, store_id)
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
160 create sequence public.dorms_seq start 1000;
163 id int not null default nextval('public.dorms_seq'),
168 dorm_id int not null,
169 room_id int not null,
170 primary key (dorm_id, room_id)
173 create sequence public.room_attributes_seq start 1000;
175 create table room_attributes (
176 id int not null default nextval('public.room_attributes_seq'),
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
187 create sequence public.students_seq start 1000;
189 create table students (
190 id int not null default nextval('public.students_seq'),
194 create table room_assignments (
195 student_id int not null,
196 dorm_id int not null,