Time
7 hours 36 minutes
Difficulty
Beginner
CEU/CPE
3

Video Transcription

00:00
I welcome the module to databases. You're in less than one database relationships, and this is lesson 1.2
00:07
table structures
00:09
and this. Listen, we're gonna take a look at what the table structure is and what it represents in databases. We'll do that with an introductory look at how to think of database tables when you knew the sequel programming or databases. In general,
00:22
it's It's easier to think of database tables as spreadsheets, the represent concepts in that database,
00:30
and we'll talk about why they get broken out this way later.
00:35
It's easy when you're new, to think that why don't I just merge all this stuff onto one table? But that actually turns into quite a pain, too,
00:43
before maintenance on and develop further as the database size increases, usually when it's a small database application and doesn't have a lot of responsibilities as faras gathering and tracking data, having even just one big database table works. But if you start trying thio,
01:03
make it a more flexible application by making it watch different types of data.
01:07
You'll start to run into a lot of trouble if you try to keep things on a very limited or even one super table,
01:12
and we'll look at that later. But first, let's look at what tables are and what they represent, and a good way to look at that. When your new is that. Hey, tables represents spreadsheets
01:23
and spreadsheets. The spreadsheets represents specific concepts. Okay, so, for example, we haven't employees spread sheet,
01:30
a state spreadsheet,
01:33
this city spread sheet
01:34
and a salary spreadsheet. If we take a look at the employee spreadsheet that will see that there are two records, which is just a minimal example, there could easily be hundreds or thousands of records on any given ah, database table, depending on what type of table and what type database you're dealing with. But in this one, we only have two.
01:53
We have two entries a kid, Parker and John Smith.
01:57
We could see that kid Parker has a primary idea of one
02:00
and a state i d. Of two. And how do we know that's an I. D. Well, we know that
02:07
there is no state that is known, is it too?
02:08
So it's a safe assumption
02:10
that there's a state table with an idea of table. Oh, I mean with it. I'm sorry with an idea of two out there
02:17
and in this employee table. The state, too,
02:23
is a foreign key, which means that in another table it's a primary key.
02:28
So let's say that we're writing a very simple query, and we wanted to know what state employees were in. And let's speed even more specific. We want to know what state Kit Parker is in. So this query would reach this table slash spreadsheet
02:40
fine kid Parker by the idea of one
02:44
and say, OK, kid, Parker's in state. To what state is that? Well, I have to go to the state table to find out.
02:52
So we traveled to the state table. Let me say, Okay, I mother stayed table. I need the state with the idea of two.
03:00
Okay, two. Is California with a coat of C A.
03:04
So when we respond when I when I quit the response to the user to say Kid belongs to California and the code for that state is C A.
03:12
Okay, that was an easy example.
03:15
Now let's let's go on to another example that uses a state table.
03:20
I say that we were looking at a city table
03:22
and we see a city of Phoenix
03:24
with an idea of one
03:27
and a state idea of one.
03:29
And we're say we write a simple query. You say I want to know what state
03:32
Phoenix belongs to.
03:35
So the quicker we would go to the city table
03:37
slash spreadsheet you wouldn't say. Okay, what state does Phoenix belong to? Okay, I have a state column with the state of 11 is not a state. So I need to go to the state table
03:50
and ah, we see that the idea of one in the state table represents Arizona.
03:54
And we can answer that question by saying OK,
03:58
by using these to spread sheets together,
04:00
I can tell the Phoenix is in Arizona
04:04
and let's do one more example.
04:08
Now we have probably the most popular table in any database the salary table, slash spreadsheet. So we're looking here and we're saying, all right,
04:17
we got a salary type of hourly. That's 15.
04:21
Who belongs to that.
04:24
Okay, that looks like that's ah.
04:26
So the idea of one
04:28
and then go back to the employees table.
04:30
You say OK,
04:31
employees idea of one kid, Parker, because then say Kit Parker gets paid $15 an hour,
04:38
and we were able to answer that question using these two tables or these spreadsheets.
04:43
And just to recap on this spreadsheet or tables, tables or spreadsheets.
04:48
Tables in the database are very similar to spreadsheets,
04:53
and usually when you're dealing with a
04:56
pretty reasonable database, you're gonna see that these tables slash spreadsheets represents specific concepts. On that, you look up answers to questions
05:05
within any program by connecting the ideas off the spreadsheets last tables together,
05:14
and that closes this lesson. I hope you enjoyed it, and I'll see you in the next lesson.

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