Learn how to create a table using the most widely-used data types (serial, varchar, integer, float, boolean, and date), and the most necessary constraints (NOT NULL and primary key).
[00:01] We're going to start with a Create Table statement and Create Directors table, some movie directors for us. Nice ID column here. Serial says that it's going to be auto-incrementing, so it would go one, two, three automatically. We don't have to worry about that.
[00:17] We'll get a name for our directors. This is going to be a string up to 200 characters long. We can just see here that the directors table is in fact created. There's no data in it. Name, ID -- that's what we expect to see.
[00:33] Directors don't really matter unless we have movies. Let's give it another ID column. We've seen that before. Again, these are kind of arbitrary. We'll give it a title. We probably want the title to be there, so we're going to say that it's not null. It can never be null.
[00:53] Let's give it a release date. We haven't seen the date definition before. It's going to be the number of stars they can have, maybe one, two, three, four, five. Let's give it a director ID to reference the directors table.
[01:09] We saw directors before. Let's see movies. There we go. A little empty table. That's what we expect.
[01:16] Just for good measure, I'm going to insert some data here. Don't worry about what these things say. I just want to take a look at what this means to have some data in our tables now, so we can have a sense of what these tables are about.
[01:29] Now we have our directors table up here. We see IDs were inserted for us, because we only inserted some names up here. The same thing happens for us down here in the movies table. We inserted a couple movies, and this is what those tables look like when we fill in some more data.