Jump to content

MySQl and inheritance


meethsingh
 Share

Recommended Posts

thanks for getting back to me.

as a simple axample, say if you had a type person with the attributes:

person(id, name, address, dob)

then you had a further two types say employee and student. each of theses types would have its own attributes:

student(department, grade, etc)

employee(position, salary, etc)

idealy you would want both student and employee to extend person and store the person attributes aswell as the individual attributes. (that is an employee also has [name, adress, etc] aswell as [salary, position etc])

i believe databases such as oracle and postgreSQL allow type inheritance. but i'm not sure about Mysql..

so i just wanted to know if Mysql supports type inheritance as i'm planning to use it on a project i'm working on.

Link to comment
Share on other sites

I am not aware of type inheritence or a lot of database stuff as i normally get the databases prebuilt and just have to develop code for them. But What i do know of Db Design is that your probelm can be solved by traditional approach.

person(id, name, address, dob)

student(department, grade, fk:person_id)

employee(position, salary, fk:person_id)

As you can see that Each Student and Employee has a Record of Person type.

If you wanted to pull out name, address , dob for a student then you would just do a Join

Link to comment
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...