Time
7 hours 36 minutes
Difficulty
Beginner
CEU/CPE
3

Video Transcription

00:00
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.
00:17
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.
00:25
And this lesson we're gonna look at creating tables in de Beaver
00:28
with that said, Let's get started.
00:31
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
00:44
and the default their final go ahead and click. Okay.
00:47
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.
00:56
And at this point, D Beaver starts the process of walking us through, creating a table. Now until we click save
01:03
this table does not exist in the database at all.
01:06
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.
01:14
Now, if we click Revert,
01:15
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.
01:25
So we'll go ahead and title this table person
01:29
on. We're just gonna add a couple columns.
01:32
I see. What's the common
01:34
attribute? First name, everyone. Most people got a first name.
01:38
I'm gonna go ahead and leave the defaults far Char
01:42
and I'm gonna create another one. Call it last name.
01:45
Good idea to keep those field separate.
01:49
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.
01:57
Well, we did a lesson on that, trying to a parse out the name.
02:00
So if we create a new column,
02:04
I'm gonna call this one s s in.
02:06
We're gonna say that it's not know and it needs to be a big ant. Unsigned.
02:12
So what does this big in unsigned me.
02:15
Well, regular imagers get a specific space of memory, a specific amount of memory,
02:21
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.
02:34
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
02:43
if you need to.
02:44
There's no negative Social Security numbers,
02:46
so I'm comfortable making that a big ant unsigned.
02:53
Okay, so we got kind of a small table. First name, last name, SSN.
02:58
Um, other fields that we would probably add would be, you know, street address, one street address to state zip code phone number,
03:07
and maybe some other good stuff again. These tables that you see
03:10
can vary wildly between application.
03:15
Ah, and the reason is is because
03:17
the
03:19
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
03:29
Let's add in a description. This table pulls people data,
03:36
all right,
03:37
and let's go ahead and click. Save
03:39
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.
03:47
We could see the comment we made.
03:50
The semicolon is important, so you notice how there's only one. This whole expression connects down
03:55
to that semicolon.
03:58
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.
04:08
It's allowed to be no
04:10
same thing with last name,
04:13
and the SS in is a big manager
04:15
unsigned, just like we selected. And it's not allowed to be. No, it has to be filled in
04:21
last. Name doesn't have to be filled in.
04:24
SSN has to be filled in. The database is protecting us when we set those rules.
04:30
Okay, so let's go ahead and click. Persist,
04:34
and we've created our table.
04:36
Our table is really there now, so if you look at the data,
04:41
it's empty. There's nothing in it.
04:43
Well, it shouldn't find anything. Yeah, okay, It found nothing. And we can look at the E r. Diagram. Very simple.
04:49
All right,
04:50
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
04:59
go to that screen
05:00
and you could add
05:01
a new column after you created the table. Let's go out and do that
05:05
new column,
05:10
and we're just gonna leave the defaults for that click save again,
05:14
and you can see that the code it's going to run altar table. ADD NEW COLUMN March Arnold
05:19
Persist.
05:21
And sure enough, if we click, refresh
05:27
when you see our new column again, there's no data added, which is why it's empty.
05:30
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

Up Next

Introduction to SQL

This introductory SQL training teaches SQL core concepts that can be applied in professional environments. Once students complete this course, they will be able to query and interact with an SQL database, and know how to design database schemas.

Instructed By

Instructor Profile Image
Kitt Parker
Instructor