I welcome back to Model three sequel programming were on Listen five tables and we're going to sub Listen 5.2 to create statement and previous lessons. We already did some table creation by using D B designer to design a schema within asked D B designer, too.
Create the sequel script that would allow us to create the skimmer within the database. And we were able to see the various table creations within that script.
And this lesson we're gonna look at creating tables in de Beaver
with that said, Let's get started.
So if I left click on databases, we're gonna go to create a new database for this, just just ah, for our table creation lesson someone a select create new database. I'm just gonna call the example. You can call it whatever you want
and the default their final go ahead and click. Okay.
Ah, left click on example. I'll expand it. I left look on tables and then right click on tables at select Great New Table.
And at this point, D Beaver starts the process of walking us through, creating a table. Now until we click save
this table does not exist in the database at all.
De Beaver is simply showing us what we're creating and up until the point we click Save it does not exist in the database.
Now, if we click Revert,
the beaver will drop what you're creating and make it look like it doesn't exist. So even though it's kind of implying that this table is here, it is not.
So we'll go ahead and title this table person
on. We're just gonna add a couple columns.
I see. What's the common
attribute? First name, everyone. Most people got a first name.
I'm gonna go ahead and leave the defaults far Char
and I'm gonna create another one. Call it last name.
Good idea to keep those field separate.
Reason being is because if you let people fill in all full name attributes, they'll do it all kinds of different ways. It will be hard to.
Well, we did a lesson on that, trying to a parse out the name.
So if we create a new column,
I'm gonna call this one s s in.
We're gonna say that it's not know and it needs to be a big ant. Unsigned.
So what does this big in unsigned me.
Well, regular imagers get a specific space of memory, a specific amount of memory,
and this could very from system to system. The point is, they get a specific amount of memory for both positive and negative numbers. So, Big ant is that we're telling the system you can have more memory per number to grow to a larger number.
And what is on science say on sign means you don't have to worry about negative numbers. Use all your memory to get to the largest positive number
There's no negative Social Security numbers,
so I'm comfortable making that a big ant unsigned.
Okay, so we got kind of a small table. First name, last name, SSN.
Um, other fields that we would probably add would be, you know, street address, one street address to state zip code phone number,
and maybe some other good stuff again. These tables that you see
can vary wildly between application.
Ah, and the reason is is because
the content of the tables really depends on what the application is trying to do. A bank is gonna need more fields than you know, a content management site
Let's add in a description. This table pulls people data,
and let's go ahead and click. Save
now. D Beaver is very nice and kind to us, and it shows us I'm gonna create this table. And this is a statement I'm running to create that table.
We could see the comment we made.
The semicolon is important, so you notice how there's only one. This whole expression connects down
Then in brackets are important. And we could see the fields that we created the first name the Bar Char 100. Which means it could be a string or text off 200 characters long.
It's allowed to be no
same thing with last name,
and the SS in is a big manager
unsigned, just like we selected. And it's not allowed to be. No, it has to be filled in
last. Name doesn't have to be filled in.
SSN has to be filled in. The database is protecting us when we set those rules.
Okay, so let's go ahead and click. Persist,
and we've created our table.
Our table is really there now, so if you look at the data,
it's empty. There's nothing in it.
Well, it shouldn't find anything. Yeah, okay, It found nothing. And we can look at the E r. Diagram. Very simple.
so that's how we create a table and d beaver. You, of course. If knew you needed to add additional columns, you would just you know, you would
a new column after you created the table. Let's go out and do that
and we're just gonna leave the defaults for that click save again,
and you can see that the code it's going to run altar table. ADD NEW COLUMN March Arnold
And sure enough, if we click, refresh
when you see our new column again, there's no data added, which is why it's empty.
So that finishes this lesson on creating tables within D Beaver. I hope you were successful. I hope you were were able to get that table created. And the next lesson we'll look at inserting some primary keys into our database as well as discussed what their purpose is. Hope to see you there and thanks for your time. By