-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcreateTables.sql
More file actions
42 lines (36 loc) · 881 Bytes
/
createTables.sql
File metadata and controls
42 lines (36 loc) · 881 Bytes
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
create table users(
u_id serial primary key, --this is my pk
name text,
photo text
);
create table places(
p_id serial primary key,
name text,
city text,
country text
);
create table sites(
site_id serial primary key,
name text,
photo text,
p_id integer references places(p_id) -- this creates my one to many relationships
);
create table diveshops(
ds_id serial primary key,
name text,
photo text,
address text,
operatinghours text
);
create table siteshops(
ss_id serial primary key,
ds_id integer references diveshops(ds_id), -- this is the info from diveshops table
site_id integer references sites(site_id)
);
create table userdives(
ud_id serial primary key,
ss_id integer references siteshops(ss_id),
review decimal,
comments text,
u_id integer references users(u_id)
);