Creating tables in PostgreSQL
Creating tables in PostgreSQL is a fundamental aspect of the database design and ease management for your client. In general, data tables serve as the foundation for structuring and storing data in a relational database management system such as PostgreSQL. By carefully designing tables, we can define the structure, relationships, and constraints that govern how data is stored and accessed. Let’s take a look:
- Open your terminal and connect to the PostgreSQL server (that you installed in the previous chapter) by running the following command:
psql -U postgres
- Create a new database called
chicago_vehicle_crash_data
:CREATE DATABASE chicago_vehicle_crash_data;
- Create a new data schema,
chicago_dmv
, within thechicago_vehicle_crash_data
database:CREATE SCHEMA chicago_dmv;
- Verify that the new schema has been created by running the following command:
\dn
- Create a new data table for the
Vehicle
dataset using thechicago_dmv
schema:CREATE...