![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, Suppose I have 2 models Human and Person and I want to inherit one from another so that I could use 'human' model/migration as a generic builder for smiliar objects as 'person', for instance this with the following table structure: human table: id weight size person table: id name surname address Is it possible to make such table inheritance in rails to be able to have 'base' model for those that are submodels with different columns? Thanks in advance! |
|
-- Posted via http://www.ruby-forum.com/. |
#3
| ||||
| ||||
|
|
Hello, Suppose I have 2 models Human and Person and I want to inherit one from another so that I could use 'human' model/migration as a generic builder for smiliar objects as 'person', |
|
for instance this with the following table structure: human table: id weight size person table: id name surname address |
|
Is it possible to make such table inheritance in rails to be able to have 'base' model for those that are submodels with different columns? |
|
Thanks in advance! |
#4
| |||
| |||
|
|
Aljaz Fajmut wrote: Hello, Suppose I have 2 models Human and Person and I want to inherit one from another so that I could use 'human' model/migration as a generic builder for smiliar objects as 'person', Your data modeling is faulty. Human is not a sub- or superclass of Person; rather, they're near synonyms. for instance this with the following table structure: human table: id weight size person table: id name surname address Where's the inheritance here? There are no fields in common except id. What do you actually want to do? Is it possible to make such table inheritance in rails to be able to have 'base' model for those that are submodels with different columns? Well, there's single-table inheritance (see the Rails docs), but it's seldom a good idea... Thanks in advance! Best, -- Marnen Laibow-Koser http://www.marnen.org marnen (AT) marnen (DOT) org |
#5
| |||
| |||
|
|
It might not be the best example but I couldnt think of better one in the moment in wrote this. I have a clear image of what I want to implement. |

|
Is this single or multi-table inheritance? |
|
Thanks for help |
#6
| |||
| |||
|
|
Aljaz Fajmut wrote: It might not be the best example but I couldnt think of better one in the moment in wrote this. I have a clear image of what I want to implement. Then you should be able to explain it more clearly. ![]() Is this single or multi-table inheritance? They're functionally more or less equivalent, although single-table inheritance is rather a perversion of the relational model. The choice between the two usually seems to be made on practical grounds. Thanks for help Best, -- Marnen Laibow-Koser http://www.marnen.org marnen (AT) marnen (DOT) org |
#7
| |||
| |||
|
|
It might not be the best example but I couldnt think of better one in the moment in wrote this. I have a clear image of what I want to implement. Is this single or multi-table inheritance? You can implement this as single table inheritance because a RDBMS |
|
Thanks for help Marnen Laibow-Koser wrote: Aljaz Fajmut wrote: Hello, Suppose I have 2 models Human and Person and I want to inherit one from another so that I could use 'human' model/migration as a generic builder for smiliar objects as 'person', Your data modeling is faulty. Human is not a sub- or superclass of Person; rather, they're near synonyms. for instance this with the following table structure: human table: id weight size person table: id name surname address Where's the inheritance here? There are no fields in common except id. What do you actually want to do? Is it possible to make such table inheritance in rails to be able to have 'base' model for those that are submodels with different columns? Well, there's single-table inheritance (see the Rails docs), but it's seldom a good idea... Thanks in advance! Best, -- Marnen Laibow-Koser http://www.marnen.org marnen (AT) marnen (DOT) org -- Posted via http://www.ruby-forum.com/. |
#8
| |||
| |||
|
|
human table: id weight size person table: id name surname address |
eople![]() |
| Thread Tools | |
| Display Modes | |
| |