I have the below UML class diagram with Abstract Class, and sub-Classes that extends from it. and i want to make an ER diagram using this class diagram.
My question is how can i represent the Abstract class in ER diagram ? as a Table ? or should i just ignore it ?
Thank you.
There are basically three choices to translate generalization into a database model
Create tables Admin
, Teacher
and Student
. Each of these table contain columns for all of the attributes and relations of User
Student
)User
are duplicated in each subclass tableUser
have to be split into three FK fields. One for Admin
, one for Teacher
and one for Student
.In this case you just have one table call User
that contains all fields of User
+ all fields of all sub-classes of User
User
dataUser
Student
and Teacher
are never filled in for Admins
and vice versaStudent
become rather complex as it is no longer a simple Not Null
constraint.In this case you create tables for each of the concrete sub-classes and you create a table for the class User
. Each of the concrete sub-class tables has a mandatory FK to User
User
Student
)Student
User
record has exactly one Admin
, Teacher
or Student
record.Which one of these options you choose depends on a number of things such as the number of sub-classes, the number of attributes in either subclass or superclass, the number of FK's to the superclass, and probably a few other things I didn't think about.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With