- Download & Install mysql
- On terminal execute
mysql -uroot -p
(enter your root mysql password) - Use script init_database.sql to set up database schema.
source /Users/...{full_path}/init_database.sql
- clone project from github
- cd to project root,
cd imdbservice
andmvn clean package
cd target/package
- copy over config.properties to target/package
cp src/config.properties target/package
- Edit the config.properties to update
userbasepath
- To populate database run:
java -Xms1024m -Xmx4096m -cp "imdbservice.jar:lib/*" com.imdb.DataUpdatingTool
- If you are running into errors in Step 9, you have 2 options
- Keep running the above command but to speed up, do individual files, i.e either title, person,
episode, rating, genre, cast -by running:
java -Xms1024m -Xmx4096m -cp "imdbservice.jar:lib/*" com.imdb.DataUpdatingTool cast
- Import database with data. Follow steps 2 & 3, but used
init_database_with_data.sql
instead. Find it here link
- Keep running the above command but to speed up, do individual files, i.e either title, person,
episode, rating, genre, cast -by running:
- To run the rest server:
java -cp "imdbservice.jar:lib/*" com.imdb.MainService
- You can now run try all of the below APIs
- NOTE: The TRY links will work only if you complete all above steps
Rest API: To fetch title data
Try : Title
Rest API: To fetch title ratings
Try : Rating
Rest API: To fetch title rating, on re-calculation. Algorithm used is: average of all episode ratings for that show
Try : New Rating
Rest API: To fetch cast info for a title. Possible cast categories are PersonCategory
Try : Cast
Rest API: To fetch person data
Try : Person
Rest API: To fetch a list of all adult titles on the service.
Try : Adult
Rest API: To fetch a list of all titles of type. Possible values { short |movie |tvMovie |tvSeries |tvEpisode |tvShort |tvMiniSeries |tvSpecial |video |videoGame }
Try : tvSeries
Rest API: To fetch a list of all titles of specified genre. Possible values for genre are { Documentary |Short |Animation |Comedy |Romance |Sport |News |Drama |Fantasy |Horror |Biography |Music |War |Crime |Western |Family |Adventure |History |Sci-Fi |Action |Mystery |Thriller |Musical |Film-Noir |Game-Show |Talk-Show |Reality-TV |Adult }
Try : Drama
Rest API: Search. Currently Supports Title and People. Implementation performs partial word match provided word begins with the query. Support filtering by query param type. if type=person returns only people, if type=title returns only title. default if no type returns both. limit: page size for pagination support. default is set at 100. offset: offset for pagination support
Try : Brad
"search": "brad",
"title": {list:[...], ...},
"people":{list:[...], ...},
"timestamp": "01/07/2019 14:10:12.040"
Rest API: To fetch a list of ratings for all titles that includes both ratings re-calculated and old ratings. Re-calculation Algorithm used is: average of all episode ratings for that show
Try : New Ratings
IMDB data integrity issues. Titles and People missing from the primary dataset. This leads to issues populating the DB, since we have foreign key relationship. DB could have been designed without foreign key relationship, but for the purpose if this exercise, we just drop the missing data.
Rest API: All titles a particular person has a role in
Rest API: All titles a particular person has played a specific role
Rest API: All episodes for a title
Rest API: All Possible Genres
Rest API: All Possible Types
5. Abstract design so that any other database can be plugged in. So the remaining part is abstraction layer for MySQLStore.
Here is how it could happen MySQLStore will implement an IDatabaseImpl IDatabaseImpl will have methods to populate, retrieve, delete, close connection, so forth IMDBService, DataUpdatingTool will be instantiated with an instance of IDatabaseImpl. MySQLStore will be that instance in this project Now in theory, IMDBService can be instantiated by any other database implementation as well