Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FOREIGN KEY (except for NULL) ... ?
Message
From
27/06/2008 15:53:50
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
01327054
Message ID:
01327371
Views:
8
>>>>I have a table that contains two classifications of items: products & services.
>>>>When it is a 'service' I need to be sure that a Header record exists for it.
>>>>To that end, I have a FOREIGN KEY on Item.HeaderID referencing Header.HeaderID.
>>>>
>>>>How can exclude the products, which have a NULL value in Item.HeaderID, from this FOREIGN KEY CONSTRAINT?
>>>>
>>>>Thanks in advance.
>>
>>>What is your database? SQL Server or VFP native tables?
>>
>>SQL-Server 2005 SP2

>Live NULL in the Item.HeaderID columnn for products. You can also add constraint that wouldn't allow to change it to anything else for products.

Thanks Segey... But I'm not sure what you mean.
Here's what I have....
ALTER TABLE [dbo].[tbSpa_Item]  WITH CHECK ADD  CONSTRAINT [FK_tbSpa_Item_tbSpa_Header] FOREIGN KEY([spi_SpaHeaderID])
REFERENCES [dbo].[tbSpa_Header] ([sph_SpaHeaderID])
Should I move the products into a separate table?
Thank you,
- Frank
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform