Created
June 16, 2014 19:24
-
-
Save ylyhlh/f390cbba6ef9cce269ac to your computer and use it in GitHub Desktop.
MovieLens Imported into MySQL
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
# http://grouplens.org/datasets/movielens/ | |
DROP TABLE IF EXISTS movies.ratings; | |
DROP TABLE IF EXISTS movies.users; | |
DROP TABLE IF EXISTS movies.movies; | |
CREATE TABLE IF NOT EXISTS movies.users ( | |
userID INT PRIMARY KEY, | |
age INT, | |
gender TEXT, | |
occupation TEXT, | |
zipcode TEXT | |
); | |
LOAD DATA LOCAL INFILE 'u.user' INTO TABLE movies.users FIELDS TERMINATED BY '|'; | |
CREATE TABLE IF NOT EXISTS movies.movies ( | |
itemID INT PRIMARY KEY NOT NULL, | |
title TEXT, | |
releaseDate DATE | |
); | |
LOAD DATA LOCAL INFILE 'u.item' INTO TABLE movies.movies FIELDS TERMINATED BY '|' | |
(itemID, title, @var3) | |
set releaseDate = STR_TO_DATE(@var3,'%d-%M-%Y'); | |
CREATE TABLE IF NOT EXISTS movies.ratings ( | |
userID INT , | |
itemID INT , | |
rating INT, | |
timestamp INT, | |
FOREIGN KEY (userID) REFERENCES users(userID), | |
FOREIGN KEY (itemID) REFERENCES movies(itemID) | |
); | |
LOAD DATA LOCAL INFILE 'u.data' | |
INTO TABLE movies.ratings; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment