SportsDB sample database

    SportsDB is a sample sports statistics dataset compiled from multiple sources and encompassing a variety of sports, including football, baseball, basketball, ice hockey, and soccer. It also cross-references many different types of content media. It is capable of supporting queries for the most intense of sports data applications, yet is simple enough for use by those with minimal database experience. The database includes over 100 tables and just as many sequences, unique constraints, foreign keys, and indexes. The dataset also includes almost 80,000 rows of data. It has been ported to MySQL, SQL Server and PostgreSQL.

    If you like details, check out this detailed entity relationship (ER) diagram.

    Follow the steps here to download and install the SportsDB sample database.

    To use the SportsDB sample database, you must have installed and configured YugabyteDB. To get up and running quickly, see .

    1. Download the SportsDB scripts

    • — Creates the tables and sequences
    • sportsdb_inserts.sql — Loads the sample data into the sportsdb database
    • — Creates the unique constraints
    • sportsdb_fks.sql — Creates the foreign key constraints
    • — Creates the indexes

    To open the Yugabyte SQL (YSQL) shell, run the ysqlsh command from the YugabyteDB root directory.

    1. yugabyte=#

    3. Create the SportsDB database

    To create the sportsdb database, run the following YSQL command

    1. CREATE DATABASE sportsdb;

    Confirm that you have the sportsdb database by listing out the databases on your cluster.

    1. yugabyte=# \l

    Connect to the sportsdb database.

    1. sportsdb=#

    To build the tables and database objects, run the following command.

    1. sportsdb=# \i share/sportsdb_tables.sql
    1. sportsdb=# \d

    5. Load sample data into the SportsDB database

    To load the sportsdb database with sample data (~80k rows), run the following command to execute commands in the file.

    To verify that you have some data to work with, you can run the following simple SELECT statement to pull data from the basketball_defensive_stats` table.

    1. sportsdb=# SELECT * FROM basketball_defensive_stats WHERE steals_total = '5';

    To create the unique constraints and foreign keys, run the following commands.

      and

      7. Create the indexes

      To create the indexes, run the following command.