Skip to content

Instantly share code, notes, and snippets.

@ylyhlh
Created June 16, 2014 19:24
Show Gist options
  • Save ylyhlh/f390cbba6ef9cce269ac to your computer and use it in GitHub Desktop.
Save ylyhlh/f390cbba6ef9cce269ac to your computer and use it in GitHub Desktop.
MovieLens Imported into MySQL
# 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