Created
August 29, 2020 05:36
-
-
Save chidindu-ogbonna/e8661cdce6d8eb39c5469b6df4c7a5c3 to your computer and use it in GitHub Desktop.
Learning SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE IF NOT EXISTS recommendation_spark; | |
USE recommendation_spark; | |
DROP TABLE IF EXISTS Recommendation; | |
DROP TABLE IF EXISTS Rating; | |
DROP TABLE IF EXISTS Accommodation; | |
CREATE TABLE IF NOT EXISTS Accommodation | |
( | |
id varchar(255), | |
title varchar(255), | |
location varchar(255), | |
price int, | |
rooms int, | |
rating float, | |
type varchar(255), | |
PRIMARY KEY (ID) | |
); | |
CREATE TABLE IF NOT EXISTS Rating | |
( | |
userId varchar(255), | |
accoId varchar(255), | |
rating int, | |
PRIMARY KEY(accoId, userId), | |
FOREIGN KEY (accoId) | |
REFERENCES Accommodation(id) | |
); | |
CREATE TABLE IF NOT EXISTS Recommendation | |
( | |
userId varchar(255), | |
accoId varchar(255), | |
prediction float, | |
PRIMARY KEY(userId, accoId), | |
FOREIGN KEY (accoId) | |
REFERENCES Accommodation(id) | |
); | |
SHOW DATABASES; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment