Hi All,
I have a problem with a table level constraint i want to create.
i have 3 tables:
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 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

or a trigger

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.