This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
|
|
|
|
|
|
Arrgghhh - looks like IE9 ate my first two posts :(
I'm trying to implement Class Table inheritance using lightspeed.
Lets say I have a Person and a Employee entity. I have created these two tables in the database each with a ID column (Person also has a PersonTypeID column as the descriminator). I have created a one-to-one foreign key constraint between Employee.Id and Person.Id.
In Lightspeed designer, I have the two entities and have created a Class Table inheritance relationship between the two, including the descriminator column and value. So far so good.
When I run the "Update from Source" command, Lightspeed offers to create a one-to-many relationship between Person and Employee. This is obviously caused by the existance of my one-to-one foreign key constraint... If I change the one-to-many relationship to a one-to-one relationship (so as to match the database schema), the generated Person entity ends up with and additional Id column (note: this is compounded if there are several descendant classes of Person, resulting in compile time errors).
So, what is the recommended database schema to support class table inheritance? Do I have to drop my one-to-one foreign key constraint in the database and rely on Lightspeed to maintain the integrity of the inheritance? - If possible I'd prefer to keep the database constraint...
Alternatively, can the Lightspeed Designer (or more specifically the "Update from Source" command) be improved to ignore a one-to-one foreign key constraint in the database, if the model includes an equivalent inheritance relationship?
Also, it'd be nice if you could add to the Lightspeed Doco your recommendations for how the database schema should look for the class table inheritance pattern.
Cheers, Greg |
|
|
[quote user="gwhite"]Do I have to drop my one-to-one foreign key constraint in the database and rely on Lightspeed to maintain the integrity of the inheritance?[/quote] Yes. [quote user="gwhite"]If possible I'd prefer to keep the database constraint...[/quote] We've had this feedback from several customers and we would like to support it but there are difficult technical issues (in particular around statement ordering in cascade deletes) and we have therefore chosen to defer support for FKs until we have time to review the implementation and ensure that we can do it in a risk-free and forward-compatible way. [quote user="gwhite"]Also, it'd be nice if you could add to the Lightspeed Doco your recommendations for how the database schema should look for the class table inheritance pattern.[/quote] Thanks for drawing this to our attention -- we'll try to make sure it gets included in the 4.0 documentation. |
|