-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PGExercises
PgExercises is a sample dataset used to power the PostgreSQL Exercises website. The site is comprised of over 80 exercises designed to be used as a companion to the official PostgreSQL documentation. The exercises on the PGExercises site range from simple SELECT statements and WHERE clauses, through JOINs and CASE statements, then on to aggregations, window functions, and recursive queries.
The dataset consists of 3 tables (members, bookings, and facilities) and table relationships as shown in the ER diagram below:
The latest instructions on how to get up and running are on our Quickstart page here:
https://docs.yugabyte.com/latest/quick-start/
You can download the Northwind database that is compatible with YugaByte DB from our GitHub repo. Here’s the two files you’ll need:
- northwind_ddl.sql which creates tables and other database objects
- northwind_data.sql which loads the sample data into Northwind
Next run the ysqlsh command to enter the PostgreSQL shell.
ysqlsh (11.2)
Type "help" for help.
postgres=#
CREATE DATABASE northwind;
Confirm we have the Northwind database by listing out the databases on our cluster.
postgres=# \l
Switch to the Northwind database.
postgres=# \c northwind
You are now connected to database "northwind" as user "postgres".
northwind=#
northwind=# \i /Users/yugabyte/northwind_ddl.sql
We can verify that all 14 of our tables have been created by executing:
northwind=# \d
Next, let’s load our database with sample data.
northwind=# \i /Users/yugabyte/northwind_data.sql
Let’s do a simple SELECT to pull data from the customers table to verify we now have some data to play with.
northwind=# SELECT * FROM customers LIMIT 2;
The dataset consists of 14 tables and the table relationships are showcased in the entity relationship diagram below:
The dataset contains the following:
- Suppliers: Suppliers and vendors of Northwind
- Customers: Customers who buy products from Northwind
- Employees: Employee details of Northwind traders
- Products: Product information
- Shippers: The details of the shippers who ship the products from the traders to the end-customers
- Orders and Order_Details: Sales Order transactions taking place between the customers & the company
That’s it! Using the command line or your favorite PostgreSQL development or administration tool, you are now ready to start exploring the Northwind database and YugaByte DB features.
Like what you see? Don't forget to star us!