Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Schema Advice

Author  Topic 

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2006-10-02 : 09:09:33
Hi All,

We have been modifying our product table, Now I have a product family table which holds a bunch of properties for products that are inherited by that family.

What I want to do is for each product in the family, copy over the standard properties. What I also want to be able to do is modify these properties so that they are specific to the product. But I need some sort of check to see if they have been inherited or entered directly. Im not sure the best way of adding this.

So;

Product Family conatains X,Y,Z as default.
All products in the family inherit X,Y,Z... someone however will be modified to say A,Y,Z and I record this.

Is it best for me to set my inheritance to grab the values once the product is selected and update the product, then if modified from the standard, hold these mods on that product and clear a bit field which would show that the product mas been modified beyond the inherited properties. Or am I not making sense? Im ok doing it, im just not sure of the best way of incorporating this into the database as I dont want to make it a mess. Thanks for your advice.

Pace,

"Impossible is Nothing"

Kristen
Test

22859 Posts

Posted - 2006-10-02 : 10:04:35
Tricky one ....

... generally with this sort of Change Over I would reset all the Children to NULL where their inheritable attribute matches the parents.

Re-curse around that until 0 rows are updated.

However, you have now created a situation where perhaps all the children were right before, but the parent was wrong, and now when the parent is changed all the children will inherit that attribute - wrongly!

The only other way is to keep all the attributes on the children and have humans remove them (perhaps as part of a planned Clean Up Exercise) when they should be the same as the parent (rather than when they happen to be the same as the parent!)

Kristen
Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2006-10-02 : 10:16:07
Ah thanks for the advice Kristen!

Fortunately in this case, neither these parent of child properties actually exist yet. So, the parent's props are to be added, then the children are to be modified so it looks like I should get away with it =)

Thanks again!

Pace

"Impossible is Nothing"
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-10-02 : 12:11:08
Ah, well in that scenario you are laughing as its all the Data Entry folk's problem!
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-02 : 12:38:22
This is probably one of the scenarios where I suggest an update-trigger.

When copying the products and the default properties, also set a new column named Inherited (bit) as true. Now the trigger does all the rest.
Whenever an UPDATE is made, set Inherited to false, even if the properties are set to original values.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -