PostgreSQL, also known as Postgres, is a flexible open-source object relational database management system (RDMS) invented at the Berkeley Computer Science Department, University of California. PostgreSQL can handle a huge variety of use cases, from single machines to data warehouses to web services with many concurrent users. PostgreSQL uses and extends SQL (hence the name), and is broadly extensible to a range of use cases beyond mere transactional data.
PostgreSQL is a back-end database for dynamic websites and web applications.
PostgreSQL supports the most important programming languages:
- Python
- Java
- C/C++
- C#
- Node.js
- Go
- Ruby
- Perl
- Tcl
The most commonly used application used to access this open source by numerous data analyst globally especially beginners, is pgAdmin 4 which comes built-int with the PostgreSQL installation, as it enables one to easily interact with the database, but in a more user-friendly way.
Even though this RDMS is super amazing, some individuals still find it difficult to import pre-built databases on it using the pgAdmin4 application, hence the purpose for this post.
In this post, I will share with you how to easily import a database into the postgreSQL using pgAdmin4 installed on a Windows OS.
For us to be able to import a database into the PostgreSQL server, we MUST have the pgAdmin4 application set up already to allow this action.
Setting the PgAdmin 4 to enable import/restoring of databases
1. Go to your PostgreSQL program file folder and locate bin
2. Click at the end of bin in the folder path to highlight path and copy it.
3. Go to File and click on Preferences
4. Scroll to Paths and click on Binary paths
5. Scroll to the “PostgreSQL Binary Path” and paste the copied file path into the Binary Path of the installed PostgreSQL server database version and check the radio button beside it.
6. Click on “Save”
Now that we have our application setup to enable import of dataset/databases, lets import the DVD Rental dataset we downloaded.
If you do not have the DVD Rental database downloaded, kindly click here to download.
Steps for Importing/restoring of databases
1. Create a database called “DVD Rental”
2. Right-click on the newly created database and click on “Restore”
3. A new window would be displayed as seen in the screenshot below. Click on the folder icon to browse the file location where you stored your downloaded dataset, ensure that you enable to file format to be “All Files”
4. Locate the folder that folder that contains the dataset (dvdrental.tar)
5. Select the dataset (dvdrental.tar) and click on the “Select button”
6. You will be redirected back to the earlier window which would have the file path of your dataset displayed in the “Filename” textbox. Click on the “Restore” button.
On successful restore of the database, you would see a notification at the bottom-right screen of your PgAdmin application as seen in the screenshot below.
Below are the tables in your newly imported database