Time
7 hours 36 minutes
Difficulty
Beginner
CEU/CPE
3

Video Transcription

00:00
I welcome back to Muzzle five sequel development. This is lesson to Thorne Keys
00:05
and we're moving into sub lesson 2.4 tags. And for the tags table, we're actually gonna have to create a pivot table. And the reason we need to great a pivot table is because tags between articles is gonna have a many too many relationship. And
00:24
what I mean is that an article
00:27
you can have many tags
00:29
and a tag
00:30
come belong to many articles.
00:33
So if something gets tagged important,
00:36
you know, you could have mark multiple articles tagged important. And then you could also have Maur tags in just that one tag
00:44
on the article as well.
00:46
So with that said, Let's get started,
00:49
We're going to Ah, right, Click on tables, Select Create New Table
00:55
and we're going to give it a name of article
01:00
underscore tags.
01:03
We're gonna add a new column. We're gonna start with the usual I D column.
01:08
We're going to make that a big end unsigned. It's not allowed to be No.
01:15
And for this we're just gonna add the columns that we need,
01:19
which will be the article on the score i G. So that we can
01:25
and became which article it belongs to.
01:27
It's not allowed to be no,
01:30
and we need to create another new column
01:34
called Tag on a Score i d.
01:38
Same thing Big Anton signed.
01:41
It's not allowed to be No,
01:42
just looked. Okay,
01:45
let's go ahead and save what we have.
01:49
Persist.
01:52
Let's add in our primary key constraint.
01:59
I'm going and save that.
02:01
Let's head back over to the columns and turn on the auto increment
02:08
or assist.
02:14
And after this finishes, let's go ahead and add in the necessary foreign keys.
02:21
So we're gonna right click great new foreign key.
02:23
Let's go ahead and performing against the articles table first, so we need to select the article I d
02:32
against the reference to column I D. Which is on the articles table.
02:37
We'll select Okay,
02:39
we need to add one more foreign key,
02:45
and this time we're gonna do the tags table
02:49
and the
02:52
column will be the tag i d.
02:53
The Russians column will be the idea on the tag stable,
02:59
and let's go ahead and save that.
03:07
It shouldn't take too long.
03:12
It seems to be taking it a little bit longer than usual.
03:15
what should be done pretty soon.
03:19
Okay, we're back. I don't know why it took it a little bit of time to perform that action. It took about a full minute to do that, but it finished.
03:28
And I bet you it looks like it already updated the E R diagram without doing a refresh, which is interesting. Usually you have to refresh or even close the application.
03:38
So within the E R diagram, we could see that the article tags table we just created sits in between the tag stable and the articles table. When a programmer or an application wants to add a tag to an article, it will first ensure that Thea tag that it's trying to add it exist.
03:59
Then it will ensure the article exists. And then it will add that as a record to the article tags table,
04:05
and that will help protect our data and integrity by assuring the tag exists and the article exists.
04:13
So that completes this lesson. Hope you were able to get those foreign keys inserted, and I'll see you in the next lesson. Thank you

Up Next

Introduction to SQL

This introductory SQL training course teaches SQL core concepts that are applied in professional environments. Once completed with the course, students 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