amtoine / animal-crossing-db-study

A project to explore noSQL languages, here redis.

Home Page:https://www.youtube.com/watch?v=G1rOthIU-uo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Database Study: Redis vs PostGreSQL

This project is a study on the Redis DataBase Management System (DBMS) and another DBMS, PostGreSQL.
The goal of this study is to shed light on the common points and the differences between the two above DBMS'.
The database used in the study is the animal-crossing database on Kaggle.

Table Of Content.

0. Organization of the repository [toc]

The repository is organized as follows:
πŸ“¦ animal-crossing-db-study
┣ πŸ“‚ tables -- all the tables from Animal Crossing New Horizons, from Kaggle.
┃ ┣ πŸ“œ accessories.csv
┃ ┣ πŸ“œ achievements.csv
┃ ┣ ...
┃ β”— πŸ“œ wallpaper.csv
┣ πŸ“‚ scripts
┃ ┣ πŸ“œ extract_values.py -- builds a '.json' containing all possible values, by column
┃ ┣ πŸ“‚ imports
┃ ┃ ┣ πŸ“œ cact4p.sql -- a .sql script that creates and loads all the tables from tables.
┃ ┃ β”— πŸ“œ redis_import_main.py -- generates a .redis file or sends tables to a redis server.
┃ β”— πŸ“‚ queries
┃    ┣ πŸ“‚ psql
┃    ┃ ┣ πŸ“œ alt-tables-timings.txt -- a summary of timings for altering queries.
┃    ┃ ┣ πŸ“œ queries.sql -- all the queries and their associated questions
┃    ┃ ┣ πŸ“‚ query_00
┃    ┃ ┃ ┣ πŸ“œ query.psql -- a query.
┃    ┃ ┃ β”— πŸ“œ question.txt -- a question.
┃    ┃ ┣ ...
┃    ┃ β”— πŸ“‚ query_38
┃    ┃    ┣ πŸ“œ query.psql -- a query.
┃    ┃    β”— πŸ“œ question.txt -- a question.
┃    β”— πŸ“œ redis_queries.py -- the redis version of the queries.
┣ πŸ“œ LICENCE
┣ πŸ“œ README.md
┣ πŸ“œ cact4p -- a bash wrapper to use cact4p.sql more easily.
┣ πŸ“œ seecsv -- a bash tool to manually look at the tables in .csv files.
┣ πŸ“œ relations.md -- a summary of the dataset and the relations between the tables.
β”— πŸ“œ xquery -- a bash tool to execute and time psql queries.

1. Prerequisites. [toc]

Install PostGreSQL: tutorial
Install Redis: tutorial

pip install redis

2. Import the database... [toc]

2.1. ... into PostGreSQL. [toc]

Run the following commands to create a new data base and automatically fill the tables:

createdb animal-crossing

and then

./cact4p tables

cact4p calls the cact4p.sql script which creates and fills all the tables for the user.
"cact4p" stands for Create Animal Crossing's Tables for (4) Postgresql.

2.2. ... into Redis. [toc]

After installing redis server, and redis-py on your computer. And making sure the redis server is running. Execute the python file to generate a redis script.
i.e. in one terminal, or in one tmux-like tool session:

redis-server

and in a another one:

python3 scripts/imports/redis_import_main.py tables

Use python3 scripts/imports/redis_import_main.py -h to learn more about the use of the python script.

3. Inspect the tables manually. [toc]

If you want to inspect the tables in tables, it can be quite tideous in the terminal without the proper tool.
This is why we introduce seecsv, a simple tool to see any .csv table inside the terminal.
Might not work perfectly with large tables, e.g. with pretty long strings, but it can give a good idea of what is inside a given table.
To use it, simply run the following:

./seecsv /path/to/table.csv

One might also want to look at the possible values seen in the tables, e.g. all possible names, all possible colors, ...
To do so, you can use the extract_values.py script in scripts with

python3 scripts/extract_values.py tables

4. Execute and time the queries. [toc]

For the psql part, one can easily execute and time the queries of the repo with the following command:

./xquery scripts/queries/psql/query_<nb>

About

A project to explore noSQL languages, here redis.

https://www.youtube.com/watch?v=G1rOthIU-uo

License:GNU General Public License v3.0


Languages

Language:Python 53.1%Language:Jupyter Notebook 43.6%Language:Shell 3.3%