constraints

Foreignkey constraint may cause cycles or multiple cascade paths?

I have a problem when i try to add constraints to my tables i get the error: Introducing FOREIGN KEY constraint 'FK74988DB24B3C886' on table 'Employee' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. My constraint is between a Code table and an empl...

How to constrain generic type to must have a construtor that takes certain parameters?(C#)

I have a wrapper generic class that intended to be used with a set of types. Those types are generated by a utility and are all derived from a base class ClientBase. While ClientBase has only a default constructor, all generated types have default constructor as well as a constructor takes a string as parameter. In the constructor of the...

Can you replace or update an SQL constraint?

I have written the following constraint for a column I've called 'grade': CONSTRAINT gradeRule CHECK grade IN (‘easy’, ‘moderate’, ‘difficult’), Is it possible to later update the gradeRule to have different values? For example, 'moderate' and 'difficult' could be changed to 'medium' and 'hard'. Thanks ...

Parameter constraints

Hello, I am using the Rhino Mocks framework. I referenced the Rhinomocks dll and everything worked fine.. but when I was trying to use the LastCall.Constraints(Is.Anything()) it says: Error The name 'Is' does not exist in the current context The same happens with Text and List constraints.. any help?? ...

Accessing private static methods from a public static context

Consider this sample class, class TargetClass { private static String SENSITIVE_DATA = "sw0rdfish"; private static String getSensitiveData() { return SENSITIVE_DATA; } } When I do this, import java.lang.reflect.Method; public class ClassPiercing { public static void main(String... args) throws Exception { ...

Constraints on Dijit DateTextBox [Valid days of the week]

Quick question about the Dijit.Form.DateTextBox http://docs.dojocampus.org/dijit/form/DateTextBox This page contains the following: "also validates against developer-provided constraints like min, max, valid days of the week, etc." I can't seem to find documentation allowing me to provide a constraint on the days of the week. For ins...

Does anyone know good Object Constraint Language (OCL) tutorial?

I came across couple of questions about OCL expressions. After reading some university slides and googling it I still cannot properly understand it. I wonder if any of you guys know any good resources that I should read to understand this stuff. Constraints that bother me: Everybody working in the department has the same manager. N...

Postgresql: deleting rows with column that references the same table takes bizzare amount of time

Sorry for a pretty specific question. I have a table (see bottom), and when I try to delete a lot of records from it, my PostgreSQL 8.2.5 spends 98% of the time doing the parent-child constraint. I'm trying to figure out what index should I add to make it go fast. I have to say that all columns on this table have either 0 or null as the...

Transaction with Read Committed Isolation Level and Table Constraints

Does table constraints execute in the same transaction? I have a transaction with Read Committed isolation level which inserts some rows in a table. The table has a constraint on it that calls a function which in turn selects some rows from the same table. It looks like the function runs without knowing anything about the transaction ...

Postgres: Table inheritance: Enforcing unique constraints across partitions?

I have a table that I would like to partition, but I don't know how to deal with the uniqueness constraints. Is it possible to create a unique constraint across multiple child tables? ...

Generics: why won't this compile?

Given the following code: class A<T> { internal void Add(T obj) { } } class C { } class B<T> where T : C { public B() { A<T> a = new A<T>(); a.Add(new C()); } } The call to Add does not compile. It does when I cast it to T first: a.Add((T)new C()); It might be the sleep deprivation, but what am I missing here? ...

Microsoft Solver Fundation tutorial ?

Hi all, I develop an application (in C# Winform) that try to solve calendar issues and time slots assignments. This should be done by contraint programming. Do you know some good url and tutorials to get start with Microsoft Solver Fundation? ...

SQL: how to enforce that only a single column is set in a group of columns

In SQL, is there a way to enforce that only one column out of a group of columns has a value, and the others are null? Maybe a constraint or trigger? This type of thing might be for a lookup table, but are there any alternate table designs that might accomplish this better? For example: ID OtherTable1ID OtherTable2ID OtherTa...

Constraint name update in PostgreSQL

Is it possible to change the constraint name in Postgres? I have a PK added with: ALTER TABLE contractor_contractor ADD CONSTRAINT commerce_contractor_pkey PRIMARY KEY(id); And I want to to have different name for it, to be consistent with the rest of the system. Shall I delete the existing PK constraint and create a new one? Or is th...

Deferrable Constraints in SQL Server

Do any versions of SQL Server support deferrable constraints (DC)? Since about version 8.0, Oracle has supported deferrable constraints - constraints that are only evaluated when you commit a statement group, not when you insert or update individual tables. Deferrable constraints differ from just disabling/enabling constraints, in that...

deferred constraint checking

Currently In our database design we have an circular reference between two entities. In other words, we have foreign keys in each table that reference each others primary key. In order to insert records in these tables we need to perform a deferred constraint checking. Is this possible in SQL Server 2008? I know Oracle DDL has specia...

Validating UPDATE and INSERT statements against an entire table

I'm looking for the best way to go about adding a constraint to a table that is effectively a unique index on the relationship between the record and the rest of the records in that table. Imagine the following table describing the patrols of various guards (from the previous watchman scenario) PK PatrolID Integer FK GuardID Integer...

Oracle unique constraint with where clause

Hi All, I have an Oracle database table that I want to apply a unique constraint on. The issue is that I only want to apply the constraint if a column in that table is null, ie. if a row does not have a deleted_date column, then apply the constraint, otherwise ignore it. This will allow for soft deleting records and ignoring constrain...

How do I specify a column to be unique in the scope of a relationship in SQL Server 2008?

It's easier with an example. I have two tables: Books and Chapters. Both have Title and Id columns. Chapters also has a Book column which is a foreign key to Books.Id. Books.Title is unique (I don't want two books with the same title). Now my problem is defining Chapter.Title uniqueness. I want it to be unique as long as Books.Id is the...

Is it possible to add a logic Constraint to a Foreign Key?

Hi folks, I've got two tables and I've added a foreign key constraint. Kewl - works great. Now, is it possible to further constrain that relationship against some data in the parent table? Basically, I have animals in the parent table, and for the child table wishto only contain data where the parent data are .... um .. mammals. eg. ...