Skip to content

Instantly share code, notes, and snippets.

@chidindu-ogbonna
Created August 29, 2020 05:36
Show Gist options
  • Save chidindu-ogbonna/e8661cdce6d8eb39c5469b6df4c7a5c3 to your computer and use it in GitHub Desktop.
Save chidindu-ogbonna/e8661cdce6d8eb39c5469b6df4c7a5c3 to your computer and use it in GitHub Desktop.
Learning SQL
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