Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
MSIL
hi
How i implement inheritance in tables on a relational database?
for example i have the members class that is a super class and it has only user name attribute.my child classes are:admin_users and other_users that derived from members super class.these child classes consists of password attribute
for that user.i want to know each work must be done: implement this hierarchy in one table in database or each class must has own table.
thanks a lot.
Posted
Updated 1-Sep-10 21:50pm
v3
Comments
Dalek Dave 2-Sep-10 3:50am    
Edited for Grammar, Syntax, Spelling and Code Block Removal.

1 solution

Unfortunately, we still lack a true Object Oriented database, and, databases are still Relational. That's why we need Object Relational mapper (ORM) between the application and the database to do database operations.

But, you can implement the similar relationship in the database, that you have in your object design. That is, you can have a Members table with only {id,Name} fields. Then, you can have User table with a column {MemberId}, referring to the Id field of the Members table. The User table will also have another column UserType for identifying the user type which points to (Admin user, or, other user) another separate table UserType{Id, Type}.
 
Share this answer
 
Comments
Dalek Dave 2-Sep-10 3:50am    
Good Answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900