unique-constraint

SQL table normalization: Simple question about restricting record participation in a many to many relation

If you have the following tables and relations: A Product table A Price Point table (one or more prices for a product) A Version table (groups of products sold in the same area) and the constraint that only one product price can exist in any given version. How would you construct the tables to reflect the constraints? To illustrate ...

Entity data model, unique index

In my entity data model I have an entity with one property as the primary key and another property that will have unique values too, so I’d like to create a unique index on that other property. The situation is very similar to the Person entity with the PersonID and PersonSSN fields. Is there any way to specify in the designer or in the...

UNIQUE constraint controlled by a bit column

Hi. I have a table, something like FieldsOnForms( FieldID int (FK_Fields) FormID int (FK_Forms) isDeleted bit ) The pair (FieldID,FormID) should be unique, BUT only if the row is not deleted (isDeleted=0). Is it possible to define such a constraint in SQLServer 2008? (without using triggers) P.S. Setting (FieldID, FormID, isDel...

How to enforce unique constraint with LINQ to SQL

Hi, I'd like to enforce a unique constraint on two columns with LINQ to SQL. I have got a constraint configured on a SQL table, but is there a way to use it with LINQ to SQL? Unique constraint is applied to two columns, both of which are foreign keys. Thank you Edit: I could catch exception, that's if a very specific exception gets t...

Best way to handle unique constraints when using Entity Framework

I'm using Entity Framework 4.0 to access data in a table with a unique column constraint. If the constraint is violated, an exception occurs when I call SaveChanges(), as expected. My question is whether I should allow the exception to be thrown in the first place. I could alternatively do a select to avoid inserting the duplicate dat...