Creating Tables
Now that you have seen how to connect to a database and issue a simple query, it's time to create some sample data to work with.
Because you are pretending to model a movie-rental business (that is, a video store), you will create tables that model the data that you might need in a video store. Start by creating three tables: tapes, customers, and rentals.
The tapes table is simple: For each videotape, you want to store the name of the movie, the duration, and a unique identifier (remember that you may have more than one copy of any given movie, so the movie name is not sufficient to uniquely identify a specific tape).
Here is the command you should use to create the tapes table:
CREATE TABLE tapes ( tape_id CHARACTER(8) UNIQUE, ...
Get PostgreSQL, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.