| | |
chicken and egg problem
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2006
Posts: 1
Reputation:
Solved Threads: 0
Hi All,
I have a problem with a table level constraint i want to create.
i have 3 tables:
products
categories
product_categories - use to connect product to categories since a product can be added to more then one category.
my problem is i want to create a contraint in the product table that makes sure all products belongs to atlist 1 category - meaning it exists in the products_categories table - but when i create a new product and before i added it to some categories i broke the constarint.
Any solutions?
I have a problem with a table level constraint i want to create.
i have 3 tables:
products
categories
product_categories - use to connect product to categories since a product can be added to more then one category.
my problem is i want to create a contraint in the product table that makes sure all products belongs to atlist 1 category - meaning it exists in the products_categories table - but when i create a new product and before i added it to some categories i broke the constarint.
Any solutions?
•
•
Join Date: Jul 2005
Posts: 483
Reputation:
Solved Threads: 19
I don't know if it is possible to do a two way foreign key constraint. I would suggest handling the problem procedurally. In other words, create a stored procedure for inserting into the product table that requires you to pass a category to be inserted into the product_categories table. and then only insert using that stored proc
![]() |
Similar Threads
- Dani's Cookbook (Geeks' Lounge)
- Strange Problem - Acer Inspire 3100 - Very Puzzling! (Troubleshooting Dead Machines)
- Excel Form - For/Next - Naming Convention Problem (Visual Basic 4 / 5 / 6)
- Gigabyte GA K8NS PRO problem with cpu overheating (Motherboards, CPUs and RAM)
- ASP.NET / C# Dynamic Control (ASP.NET)
- Problem starting windows xp.. (Windows NT / 2000 / XP)
- Windows XP Startup Problem (Windows NT / 2000 / XP)
Other Threads in the MS SQL Forum
- Previous Thread: SQL problem - table names as variables
- Next Thread: HELP - Invalid object error related to sqlole null bug in MSSQL 2000
| Thread Tools | Search this Thread |
autogrowth connectingtodatabaseinuse count cursor data database datepart dbsize deadlock delete_trigger highperformancecomputing hpc hpcserver2008 ibm iis loop maximum microsoft ms mssql multiple multithreading news number permission query reporting result server services sets source sql sqlserver sqlserver2005 supercomputing tables uniqueid update view





