-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.sql
38 lines (32 loc) · 923 Bytes
/
database.sql
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
-- Database name should be: giphy_search_favorites
-- Categories table:
CREATE TABLE "categories" (
"id" SERIAL PRIMARY KEY,
"name" VARCHAR (100) NOT NULL
);
-- Default categories. You may change these. 🙂
INSERT INTO "categories"
("name")
VALUES
('wild'),
('uproarious'),
('poignant'),
('felicitous'),
('whimsical');
-- Favorites table:
-- You'll need a "favorites" table for storing each instance of
-- a Giphy image that has been "favorited."
-- Each favorite image can be assigned one of the existing
-- categories via foreign key. This is a one-to-many relationship:
-- One favorite has one category.
-- One category can be had by many favorites.
CREATE TABLE favorites (
id SERIAL PRIMARY KEY,
url text,
title text
);
create table favorites_categories (
id SERIAL primary key,
category_id integer REFERENCES categories,
favorites_id integer REFERENCES favorites
);