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.
And this is helping us prepare for seeding the database.
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.
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.
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.
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.
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
go to your folder. Shared app switched that you shared database
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.
where they go, data.
We'll go ahead and click the plus,
and I'm just going to give it a name of test building
at this one
anywhere City ese.
We'll go ahead and leave the created at and updated at blank. Someone is safe.
There's our building, and next we have
rooms. So let me go ahead and create a room
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.
So click the plus sign again.
I must say, this is a test room.
Max Capacity is 30.
Building idea is one that
remember that building I d has to exist. We've only created one so only I d one exist.
If I put a to in here, that will, of course, fail.
OK, but if I switch it to a one, it will be successful.
on, Let's go ahead and look at our next table. Courses create courses table. OK,
so there's our courses.
Go ahead. And
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
source code will be 1234 f
Max students will say is 50.
I meant 500. Sure. 25 for the men
start date and date created at Think I have to have that filled in.
I think it's a time stamp. Two So 00
Which would be midnight.
Let's see if that works.
Yep, sure did.
And then our next one is users. Some go to users.
You had a hit plus
first and will be cyber.
Last name is gonna be I t
The numbers will be 1234567890
Maybe I didn't leave these blank and click save
we have our user in.
Let's go ahead and move on to our grades table. I'm gonna add in more than one grade.
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
save. It's added another one.
He's already is one course ideas. One
All right, so we got a couple of grades in there
user types table.
and we're gonna click. Add
is a student is description.
Go ahead and click Save.
And what is our next one
so we're gonna go ahead and add
is already one type i d. Of one course I d one
now we have that unique constraint on the on this table. So if I actually tried to do that again user one
type one course one because of that unique constraint, this is going to get rejected.
And that makes a lot of sense because I can't enroll in the same course twice,
so I'm going and cancel that.
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.
So let's go ahead and head over to the summary,
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.
And we've prepped and confirmed we're ready to begin the seeding process. Once that's done,
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
vast we want our testing to be.
So that completes this lesson, and I hope to see in the next thank you