Using PostgreSQL: Creating a Database - Are we creating a new database inside the database dq?

Screen Link:
https://app.dataquest.io/m/114/using-postgresql/8/creating-a-database

For this Step, we -

  1. Connect to the dq database with the user dq .
  2. Create a database called income where the owner is the user dq .

We connected to the database dq. And then we created a new database, income.

So, income is a database inside of the database dq? Or it’s a completely separate database within the same server that stores dq as well?

Related question to this -

How was dq created given that we need to connect to a database to be able to run queries on it? Clearly, a server was created first, and then dq was added to it as a database. But how was dq as a database created if not through SQL commands? Is that something that will be taught later?

hey @the_doctor

This post is similar to your 1st question, here

For the second question, we may not how “dq” database was created for the mission. But it’s not that difficult to decode a database definition. All we need, is access to it’s SQL script.

This script is like our python code. If you look at it in pgAdmin it will be something like this:

Each keyword like Owner, Encoding is part of the definition of that database.

This only gives us how the database was created or precisely it’s definition. For each table or view or anything that was created within the database, the SQL Script for that component will have to be checked. For example - facts table within Chinook database. We will have to check the script for facts table to see it’s structure.

1 Like