constraints
Prolog Constraint Processing : Packing Squares
For each square, define X and Y variables that denote the upper left corner. These variable will have domains 1..10-L, where L is the length of the square. If you set the domain to 1..10, the squares may be placed partly outside your 10×10 rectangle. Then you can post constraints for each pair of rectangles … Read more
Conditional SQLite check constraint?
How about: CHECK (status = “Current” or (status = “Complete” and enddate is not null))
How to write a constraint concerning a max number of rows in postgresql?
Quassnoi is right; a trigger would be the best way to achieve this. Here’s the code: CREATE OR REPLACE FUNCTION enforce_photo_count() RETURNS trigger AS $$ DECLARE max_photo_count INTEGER := 10; photo_count INTEGER := 0; must_check BOOLEAN := false; BEGIN IF TG_OP = ‘INSERT’ THEN must_check := true; END IF; IF TG_OP = ‘UPDATE’ THEN IF … Read more
Can you use “where” to require an attribute in c#?
Nope, I’m afraid not. The only things you can do with constraints are: where T : class – T must be a reference type where T : struct – T must be a non-nullable value type where T : SomeClass – T must be SomeClass or derive from it where T : ISomeInterface – T … Read more
How to get the name of a unique constraint in postgresql?
That is something like (for single column constaint): tableName_columnName_key To get constaint name write (in psql): \d tableName or use pg_constraint system catalog: SELECT conname FROM pg_constraint WHERE conrelid = (SELECT oid FROM pg_class WHERE relname LIKE ‘tableName’); Also you can get it from pgAdmin in objects tree.
Is there a generic constraint I could use for the + operator?
There are no such devices in C#. A few options are available, though: in C# 4.0 and .NET 4.0 (or above), use dynamic, which supports + but offers no compile time checking in .NET 3.5 (or above), MiscUtil offers an Operator class which makes operators available as methods – again, without any compile-time checking So … Read more
Deferrable Constraints in SQL Server
OT: There are IMHO quite a few things SQL Server does not support, but would make sense in an enterprise environment: Deferrable constraints as mentioned here MARS: Just why do you need to set an option for something entirely natural? CASCADE DELETE constraints: SQL Server does only allow one single cascadation path for a given … Read more
Solution for overloaded operator constraint in .NET generics
There is no immediate answer; operators are static, and cannot be expressed in constraints – and the existing primatives don’t implement any specific interface (contrast to IComparable[<T>] which can be used to emulate greater-than / less-than). However; if you just want it to work, then in .NET 3.5 there are some options… I have put … Read more
How to give a unique constraint to a combination of columns in Oracle?
Create a unique key on those columns ALTER TABLE YourTable add CONSTRAINT YourTable_unique UNIQUE (B, C, D); Oracle/PLSQL: Unique Constraints