Time
7 hours 36 minutes
Difficulty
Beginner
CEU/CPE
3

Video Transcription

00:00
I welcome back to module to databases. This is lesson to skim a design, and we are in sub lesson 2.6 polymorphic models. So what is a polymorphic model? Well, you don't have to get too scared of the term if we look at the meaning of the term, it simply means that many forms
00:17
and the way that gets applied in a lot of database applications is via e
00:21
type calm. So if we pull up the note table from the axiomatic and database and we focus on this entity type column
00:30
and we go on, look at the data
00:31
and we filter on entity type by just clicking a little filter button and dear,
00:37
we'll see all of these different types that we can filter on, and these types are different object types within the application. So let's say I want to find the employees notes. All I have to do is go to the E p employee type. I'll select that that adds the entity type constraint at the top. This is what D Beaver does for us
00:57
that was
00:57
writing a query, though I would simply add this constraint to that query to get the employees notes.
01:03
And that pulls out all the employees notes now in similar fashion. If I wanted to get a different type, I would just add a constraint that focused on that type.
01:15
Well, there's the email account type.
01:19
And indeed, even if we get rid of this, that will turn off the filter. We'll see all the types again,
01:25
and that's it. That's the type column being used to create a polymorphic model within the database. Now, how would you solve this problem if you didn't want to use the type column? For some reason, you know you didn't know about it or you didn't want to use it Well, what you might see someone do is make a bunch of tables for each different type of note. Now that's not something you want to do, and that's
01:46
pretty apparent pretty quickly. Within the automatic a database.
01:49
We can already see that that would be somewhere along the lines off,
01:53
maybe 30 to 40 tables. I didn't count him, but it looks like it would be close to that, and that's a lot more tables than we need when we can just use one table to solve it. by just including the type within that table itself.
02:09
So that completes this lesson. We discussed the polymorphic table by using the note table for Mathematica as an example, and we were able to see that this was a polymorphic table because of the entity type column, which indicates different types of notes. I hope you enjoy this lesson and I hope to see you in the next thank you.

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