Time
9 hours 41 minutes
Difficulty
Intermediate
CEU/CPE
10

Video Transcription

00:00
I welcome back to module four. This is less than 4.6 implement model relationships to. And this lesson we're gonna prep for testing with Tinker, and we're going to do this by adding a few records to each table. Then in the next lesson will test with Tinker to verify that our relationships and our models are set up correctly.
00:19
And this is helping us prepare for seeding the database.
00:23
So following this lesson in the next couple of lessons, we'll set up our database seating. Now, with that said, let's get started.
00:33
All right, welcome back. And if you happen to be using D Beaver, you can always look at your diagram of your database by clicking on the database and go into the ER diagram tab.
00:43
Ah, and you will be able to see all your constraints. Now, that doesn't show you the relationships as clean Lee as the er de diagram here. We're gonna see this is a one to many.
00:53
Now that said, we need to add records for testing with Tinker. We need to make sure we add these in the right order because we do have our constraints in place.
01:02
So we have to. We can't add a user and the user course table that doesn't exist yet. So an easy way to make sure we go in the right order is to
01:11
go to your folder. Shared app switched that you shared database
01:18
migrations.
01:19
We could see the order. We create things in. So the 1st 1 is the buildings table. Let's add a record to the buildings table.
01:27
Oh,
01:30
where they go, data.
01:34
We'll go ahead and click the plus,
01:36
and I'm just going to give it a name of test building
01:42
at this one
01:46
address to
01:48
anywhere City ese.
01:52
123456
01:55
We'll go ahead and leave the created at and updated at blank. Someone is safe.
02:00
There's our building, and next we have
02:05
rooms. So let me go ahead and create a room
02:08
so a room will have to belong to building Building I d. One you could, ADM. Or if you wanted to, just to test even further.
02:16
So click the plus sign again.
02:20
I must say, this is a test room.
02:23
Max Capacity is 30.
02:25
Building idea is one that
02:29
remember that building I d has to exist. We've only created one so only I d one exist.
02:34
If I put a to in here, that will, of course, fail.
02:38
OK, but if I switch it to a one, it will be successful.
02:43
All right,
02:46
on, Let's go ahead and look at our next table. Courses create courses table. OK,
02:52
so there's our courses.
02:54
Go ahead. And
02:57
at one,
02:59
we have a gave my room idea an idea to, But if it gave you an idea of one, you'll need to use that one
03:06
source code will be 1234 f
03:09
Test course
03:13
Max students will say is 50.
03:15
I meant 500. Sure. 25 for the men
03:20
start date and date created at Think I have to have that filled in.
03:25
So
03:27
I see
03:29
Doesn't 1911
03:35
I think it's a time stamp. Two So 00
03:38
00
03:39
00
03:42
Which would be midnight.
03:46
Let's see if that works.
03:47
Yep, sure did.
03:50
Okay.
03:53
And then our next one is users. Some go to users.
03:59
You had a hit plus
04:00
first and will be cyber.
04:03
Last name is gonna be I t
04:06
The numbers will be 1234567890
04:11
The one
04:15
on to
04:18
anywhere.
04:21
Z
04:24
23456
04:26
Maybe I didn't leave these blank and click save
04:30
we have our user in.
04:31
Let's go ahead and move on to our grades table. I'm gonna add in more than one grade.
04:39
So, user, we're going to click the add button user and he's gonna be one course ideal be one letter grade will be a great score. Will be five
04:49
save. It's added another one.
04:54
He's already is one course ideas. One
04:57
be
04:58
three
04:59
save.
05:00
All right, so we got a couple of grades in there
05:03
user types table.
05:06
All right,
05:09
and we're gonna click. Add
05:12
se
05:14
Student
05:16
is a student is description.
05:20
Go ahead and click Save.
05:24
And what is our next one
05:29
user courses?
05:30
All right,
05:32
so we're gonna go ahead and add
05:35
is already one type i d. Of one course I d one
05:41
save.
05:43
All right,
05:45
now we have that unique constraint on the on this table. So if I actually tried to do that again user one
05:50
type one course one because of that unique constraint, this is going to get rejected.
05:56
And that makes a lot of sense because I can't enroll in the same course twice,
06:02
so I'm going and cancel that.
06:06
So we've added all the data records we need in the database to test with Tinker and verify that are level models are working correctly, and we'll handle that in the next lesson.
06:16
So let's go ahead and head over to the summary,
06:18
and that brings us to the lesson 4.6 employment model to summary. What did we do in this lesson? We manually added some database records. This is this will allow us to confirm our models are working correctly. And the next lesson we're going to use Tinker to verify that our model relationships are functioning as we expect.
06:40
And we've prepped and confirmed we're ready to begin the seeding process. Once that's done,
06:45
the seeding process will allow for superior testing because we will be able to load our database with hundreds or thousands of records, depending on how
06:54
vast we want our testing to be.
06:56
So that completes this lesson, and I hope to see in the next thank you

Up Next

Intermediate SQL

This free course introduces the student to intermediate concepts found in the implementation and application of Structured Query Language (SQL) within professional business environments.

Instructed By

Instructor Profile Image
Kitt Parker
Instructor