-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.sql
More file actions
37 lines (31 loc) · 849 Bytes
/
schema.sql
File metadata and controls
37 lines (31 loc) · 849 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
DROP DATABASE if exists sdc_project;
CREATE DATABASE sdc_project;
USE sdc_project;
CREATE TABLE listings (
id int NOT NULL AUTO_INCREMENT,
listingPrice int NOT NULLAUTO_INCREMENT,
listingBedsNumber int,
listingType VARCHAR(30),
PRIMARY KEY (id)
);
CREATE TABLE recommendations (
listing_id int NOT NULL,
id int NOT NULL AUTO_INCREMENT,
title VARCHAR(50),
price int,
homeType VARCHAR(30),
bedsNumber int,
reviewsAverage float,
numberOfReviews int,
likedStatus BOOLEAN,
plusStatus BOOLEAN,
image1 VARCHAR(100),
image2 VARCHAR(100),
image3 VARCHAR(100),
PRIMARY KEY (id),
FOREIGN KEY (listing_id) REFERENCES listings (id)
);
ALTER TABLE recommendations ADD INDEX (listing_id);
OPTIMIZE TABLE recommendations;
CREATE INDEX recommendation_inx ON recommendations(id);
CREATE INDEX listing_inx ON listings(id);