-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatchMaker.sql
More file actions
33 lines (29 loc) · 776 Bytes
/
matchMaker.sql
File metadata and controls
33 lines (29 loc) · 776 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
DROP TABLE IF EXISTS Persons_Hobbies;
DROP TABLE IF EXISTS Hobbies;
DROP TABLE IF EXISTS Persons;
CREATE TABLE Persons (
cod_person SERIAL PRIMARY KEY,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
birth_date DATE NOT NULL,
age INT,
photo bytea default null
);
CREATE TABLE Hobbies (
cod_hobby SERIAL PRIMARY KEY,
hobby_name VARCHAR(255)
);
INSERT INTO Hobbies (hobby_name) VALUES
('Sports'),
('Music'),
('Reading'),
('Traveling'),
('Cooking'),
('Movies'),
('Art'),
('Games');
CREATE TABLE Persons_Hobbies (
cod_person INT REFERENCES Persons(cod_person) ON UPDATE CASCADE ON DELETE CASCADE,
cod_hobby INT REFERENCES Hobbies(cod_hobby),
PRIMARY KEY (cod_person, cod_hobby)
);