Commit 4f1f1e9f authored by Daniel Kim's avatar Daniel Kim
Browse files

merge

parents 3b6606f4 de6e4509
import java.util.HashMap;
import java.util.Scanner;
import java.rmi.server.SocketSecurityException;
import java.sql.*;
import java.text.SimpleDateFormat;
......@@ -671,22 +672,33 @@ public class ClientApplication {
}
maxId++;
Statement updateId = c.createStatement();
String updateIdQuery = "update MaxIDs set entityNum = " + maxId + " where entityName = 'person'";
updateId.execute(updateIdQuery);
Statement st = c.createStatement();
<<<<<<< HEAD
String query = String.format("insert into People values ('%s', '%s', '%s', '%s', '%s', '%s')",
"nm" + maxId,
values.get(name),
=======
String query = String.format("insert into People values ('%s', '%s', '%s', '%s', '%s', '%s', '%s')",
"nm" + maxId,
values.get(name),
>>>>>>> ap
values.get(originalName),
values.get(height),
values.get(biography),
values.get(birthDetails),
new java.sql.Timestamp(format.parse(values.get(dateOfBirth)).getTime())
new java.sql.Timestamp(format.parse(values.get(dateOfBirth) + " 00:00:00").getTime())
);
ResultSet rs = st.executeQuery(query);
st.execute(query);
if (values.containsKey(dateOfDeath) || values.containsKey(placeOfDeath) || values.containsKey(reasonOfDeath)) {
Statement st2 = c.createStatement();
String deathQuery = String.format("insert into DeadPeople values ('%s', '%s', '%s', '%s')",
"nm" + maxId,
<<<<<<< HEAD
new java.sql.Timestamp(format.parse(values.get(dateOfDeath)).getTime()),
values.get(placeOfDeath),
values.get(reasonOfDeath)
......@@ -706,12 +718,21 @@ public class ClientApplication {
}
else {
System.out.println("Error updating max id");
=======
new java.sql.Timestamp(format.parse(values.get(dateOfDeath) + " 00:00:00").getTime()),
values.get(placeOfDeath),
values.get(reasonOfDeath)
);
st2.execute(deathQuery);
>>>>>>> ap
}
} catch (Exception e) {
System.out.println(e);
}
break;
default:
System.out.println("Invalid command " + command);
break;
}
}
}
......
public class Constants {
public static final String db_url = "jdbc:mysql://marmoset03.shoshin.uwaterloo.ca";
public static final String db_user = "";
public static final String db_pwd = "";
public static final String db_url = "jdbc:mysql://127.0.0.1:3306";
public static final String db_user = "root";
public static final String db_pwd = "db4kimece356";
}
......@@ -77,8 +77,8 @@ create table People (
dateOfBirth datetime
);
alter table People add primary key (personID);
replace into People (personID, firstName, lastName, bio, birthDetails, dateOfBirth)
select personID, firstName, lastName, bio, birthDetails, dateOfBirth from ImdbNames;
replace into People (personID, firstName, lastName, height, bio, birthDetails, dateOfBirth)
select personID, firstName, lastName, height, bio, birthDetails, dateOfBirth from ImdbNames;
create table DeadPeople (
personID char(9) not null,
......@@ -197,181 +197,181 @@ delimiter ;
call loadGenre();
-- country stuff
create table Countries (
country varchar(128) not null
);
alter table Countries add primary key (country);
-- create table Countries (
-- country varchar(128) not null
-- );
-- alter table Countries add primary key (country);
drop table if exists temp;
create table temp (val varchar(128));
drop procedure if exists parseCountry;
delimiter ;;
create procedure parseCountry() begin
declare n int default 0;
declare i int default 0;
select count(distinct country) from ImdbMovies into n;
insert into temp (val) select distinct country from ImdbMovies;
set i = 0;
while i < n do
set @s = concat(
"replace into Countries (country) values ('",
replace(
replace(
replace(
(select val from temp limit i, 1),
"'",
""
),
",",
"'),('"
),
" ",
""
),
"');"
);
prepare stmt from @s;
execute stmt;
set i = i + 1;
end while;
end;
;;
delimiter ;
call parseCountry();
drop table if exists temp;
alter table Countries add index countryIndex(country);
-- drop table if exists temp;
-- create table temp (val varchar(128));
-- drop procedure if exists parseCountry;
-- delimiter ;;
-- create procedure parseCountry() begin
-- declare n int default 0;
-- declare i int default 0;
-- select count(distinct country) from ImdbMovies into n;
-- insert into temp (val) select distinct country from ImdbMovies;
-- set i = 0;
-- while i < n do
-- set @s = concat(
-- "replace into Countries (country) values ('",
-- replace(
-- replace(
-- replace(
-- (select val from temp limit i, 1),
-- "'",
-- ""
-- ),
-- ",",
-- "'),('"
-- ),
-- " ",
-- ""
-- ),
-- "');"
-- );
-- prepare stmt from @s;
-- execute stmt;
-- set i = i + 1;
-- end while;
-- end;
-- ;;
-- delimiter ;
-- call parseCountry();
-- drop table if exists temp;
-- alter table Countries add index countryIndex(country);
create table CountriesInMovies (
movieID char(9) not null,
country varchar(64) not null
);
alter table CountriesInMovies add primary key (movieID, country);
alter table CountriesInMovies add foreign key (movieID) references Movies(movieID);
alter table CountriesInMovies add foreign key (country) references Countries(country);
-- create table CountriesInMovies (
-- movieID char(9) not null,
-- country varchar(64) not null
-- );
-- alter table CountriesInMovies add primary key (movieID, country);
-- alter table CountriesInMovies add foreign key (movieID) references Movies(movieID);
-- alter table CountriesInMovies add foreign key (country) references Countries(country);
drop procedure if exists loadCountry;
delimiter ;;
create procedure loadCountry() begin
declare n int default 0;
declare i int default 0;
select count(*) from ImdbMovies into n;
set i = 0;
while i < n do
set @s = concat(
"replace into CountriesInMovies (movieID, country) values ('",
(select movieID from ImdbMovies limit i, 1),
"','",
replace(
replace(
replace(
(select country from ImdbMovies limit i, 1),
"'",
""
),
",",
concat("'),('", (select movieID from ImdbMovies limit i, 1), "','")
),
" ",
""
),
"');"
);
prepare stmt from @s;
execute stmt;
set i = i + 1;
end while;
end;
;;
delimiter ;
call loadCountry();
-- drop procedure if exists loadCountry;
-- delimiter ;;
-- create procedure loadCountry() begin
-- declare n int default 0;
-- declare i int default 0;
-- select count(*) from ImdbMovies into n;
-- set i = 0;
-- while i < n do
-- set @s = concat(
-- "replace into CountriesInMovies (movieID, country) values ('",
-- (select movieID from ImdbMovies limit i, 1),
-- "','",
-- replace(
-- replace(
-- replace(
-- (select country from ImdbMovies limit i, 1),
-- "'",
-- ""
-- ),
-- ",",
-- concat("'),('", (select movieID from ImdbMovies limit i, 1), "','")
-- ),
-- " ",
-- ""
-- ),
-- "');"
-- );
-- prepare stmt from @s;
-- execute stmt;
-- set i = i + 1;
-- end while;
-- end;
-- ;;
-- delimiter ;
-- call loadCountry();
-- language stuff
create table Languages (
language varchar(128) not null
);
alter table Languages add primary key (language);
-- create table Languages (
-- language varchar(128) not null
-- );
-- alter table Languages add primary key (language);
drop table if exists temp;
create table temp (val varchar(128));
drop procedure if exists parseLanguage;
delimiter ;;
create procedure parseLanguage() begin
declare n int default 0;
declare i int default 0;
select count(distinct language) from ImdbMovies into n;
insert into temp (val) select distinct language from ImdbMovies;
set i = 0;
while i < n do
set @s = concat(
"replace into Languages (language) values ('",
replace(
replace(
replace(
(select * from temp limit i, 1),
"'",
""
),
", ",
"'),('"
),
" ",
""
),
"');"
);
prepare stmt from @s;
execute stmt;
set i = i + 1;
end while;
end;
;;
delimiter ;
call parseLanguage();
alter table Languages add index languageIndex(language);
-- drop table if exists temp;
-- create table temp (val varchar(128));
-- drop procedure if exists parseLanguage;
-- delimiter ;;
-- create procedure parseLanguage() begin
-- declare n int default 0;
-- declare i int default 0;
-- select count(distinct language) from ImdbMovies into n;
-- insert into temp (val) select distinct language from ImdbMovies;
-- set i = 0;
-- while i < n do
-- set @s = concat(
-- "replace into Languages (language) values ('",
-- replace(
-- replace(
-- replace(
-- (select * from temp limit i, 1),
-- "'",
-- ""
-- ),
-- ", ",
-- "'),('"
-- ),
-- " ",
-- ""
-- ),
-- "');"
-- );
-- prepare stmt from @s;
-- execute stmt;
-- set i = i + 1;
-- end while;
-- end;
-- ;;
-- delimiter ;
-- call parseLanguage();
-- alter table Languages add index languageIndex(language);
create table LanguagesInMovies (
movieID char(9) not null,
language varchar(128) not null
);
alter table LanguagesInMovies add primary key (movieID, language);
alter table LanguagesInMovies add foreign key (movieID) references Movies(movieID);
alter table LanguagesInMovies add foreign key (language) references Languages(language);
-- create table LanguagesInMovies (
-- movieID char(9) not null,
-- language varchar(128) not null
-- );
-- alter table LanguagesInMovies add primary key (movieID, language);
-- alter table LanguagesInMovies add foreign key (movieID) references Movies(movieID);
-- alter table LanguagesInMovies add foreign key (language) references Languages(language);
drop procedure if exists loadLanguage;
delimiter ;;
create procedure loadLanguage() begin
declare n int default 0;
declare i int default 0;
select count(*) from ImdbMovies into n;
set i = 0;
while i < 5000 do
set @s = concat(
"replace into LanguagesInMovies (movieID, language) values ('",
(select movieID from ImdbMovies limit i, 1),
"','",
replace(
replace(
replace(
(select language from ImdbMovies limit i, 1),
"'",
""
),
", ",
concat("'),('", (select movieID from ImdbMovies limit i, 1), "','")
),
" ",
""
),
"');"
);
prepare stmt from @s;
execute stmt;
set i = i + 1;
end while;
end;
;;
delimiter ;
call loadLanguage();
-- drop procedure if exists loadLanguage;
-- delimiter ;;
-- create procedure loadLanguage() begin
-- declare n int default 0;
-- declare i int default 0;
-- select count(*) from ImdbMovies into n;
-- set i = 0;
-- while i < 5000 do
-- set @s = concat(
-- "replace into LanguagesInMovies (movieID, language) values ('",
-- (select movieID from ImdbMovies limit i, 1),
-- "','",
-- replace(
-- replace(
-- replace(
-- (select language from ImdbMovies limit i, 1),
-- "'",
-- ""
-- ),
-- ", ",
-- concat("'),('", (select movieID from ImdbMovies limit i, 1), "','")
-- ),
-- " ",
-- ""
-- ),
-- "');"
-- );
-- prepare stmt from @s;
-- execute stmt;
-- set i = i + 1;
-- end while;
-- end;
-- ;;
-- delimiter ;
-- call loadLanguage();
-- production company stuff
create table ProductionCompany (
......
......@@ -23,7 +23,7 @@ create table ImdbMovies (
userScore float,
criticScore float
);
load data infile '/var/lib/mysql-files/03-Movies/IMDb movies.csv' ignore into table ImdbMovies
load data infile 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/IMDb movies.csv' ignore into table ImdbMovies
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
......@@ -52,7 +52,7 @@ create table ImdbNames (
spousesWithChildren int,
children int
);
load data infile '/var/lib/mysql-files/03-Movies/IMDb names.csv' ignore into table ImdbNames
load data infile 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/IMDb names.csv' ignore into table ImdbNames
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
......@@ -82,7 +82,7 @@ create table ImdbTitlePrincipals (
job varchar(256),
characters varchar(512)
);
load data infile '/var/lib/mysql-files/03-Movies/IMDb title_principals.csv' ignore into table ImdbTitlePrincipals
load data infile 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/IMDb title_principals.csv' ignore into table ImdbTitlePrincipals
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
......@@ -114,7 +114,7 @@ create table MojoBudgetData (
genre4 varchar(16),
link varchar(64)
);
load data infile '/var/lib/mysql-files/03-Movies/Mojo_budget_data.csv' ignore into table MojoBudgetData
load data infile 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/Mojo_budget_data.csv' ignore into table MojoBudgetData
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
......@@ -149,7 +149,7 @@ create table MojoBudgetUpdate (
genre4 varchar(16),
html varchar(64)
);
load data infile '/var/lib/mysql-files/03-Movies/Mojo_budget_update.csv' ignore into table MojoBudgetUpdate
load data infile 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/Mojo_budget_update.csv' ignore into table MojoBudgetUpdate
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
......@@ -183,7 +183,7 @@ create table MoviesMetadata (
score float,
votes int
);
load data infile '/var/lib/mysql-files/03-Movies/movies_metadata.csv' ignore into table MoviesMetadata
load data infile 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/movies_metadata.csv' ignore into table MoviesMetadata
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment