constraints

Fix ORA-02273: this unique/primary key is referenced by some foreign keys

Trying to drop a unique constraint I've got such error: ORA-02273: this unique/primary key is referenced by some foreign keys How to find the list of foreign keys by which my unique constraint is referenced? ...

How to write a constraint concerning a max number of rows in postgresql?

Hi, I think this is a pretty common problem. I've got a table user(id INT ...) and a table photo(id BIGINT, owner INT). owner is a reference on user(id). I'd like to add a constraint to the table photo that would prevent more than let's say 10 photos to enter the database for each users. What's the best way of writing this? Thx! ...

View All Table / Database Constraints in MySQL

How do you view all the constraints (Primary keys, Secondary keys, Assertions , Triggers, etc) in a MySQL Database / Table in the command line environment. ...

Latin squares generator? (Sudoku-like constraint problem)

Purpose We're designing a Latin square (sudoku-like sequence) for an experimental design that needs to follow these constraints: Values cannot be repeated in a row Values cannot be repeated in a column Values cannot be repeated pairwise in any two rows Example for the first 3 constraints: 2 3 5 7 11 13 7 2 11 ...

Database constraint violation ignored during SubSonic Save()?

In the following code, if one of the values assigned violates a database constraint, the Save() updates the record with the other good values. However, the database constraint does not appear to bubble up and and be caught by SubSonic. Does SubSonic provide a way to catch constraint violations like this? try { OutboundShipmentControlle...

MySQL foreign key problem

A client of mine recently formatted his machine and re-installed MySQL Server and my application. He complained that deleting records from master table is not affecting the child tables. I requested him to send the backup of the database. When I restored the database, I found that the Table Engine has changed to MyISAM whereas they were ...

How to user Hibernate @Valid constraint with Spring 3.x?

I am working on simple form to validate fields like this one. public class Contact { @NotNull @Max(64) @Size(max=64) private String name; @NotNull @Email @Size(min=4) private String mail; @NotNull @Size(max=300) private String text; } I provide getter and setters hibernate dependencies ...

SQL DROP TABLE foreign key constraint

If I want to delete all the tables in my database like this, will it take care of the foreign key constraint? If not, how do I take care of that first? GO IF OBJECT_ID('dbo.[Course]','U') IS NOT NULL DROP TABLE dbo.[Course] GO IF OBJECT_ID('dbo.[Student]','U') IS NOT NULL DROP TABLE dbo.[Student] ...

Compute a list of distinct odd numbers (if one exists), such that their sum is equal to a given number.

:- use_module(library(clpfd)). % load constraint library % [constraint] Compute a list of distinct odd numbers (if one exists), such that their sum is equal to a given number. odd(Num) :- Num mod 2 #= 1. sumOfList([],N,N) :- !. sumOfList([H|T],Counter,N) :- NewN #= H + Counter, sumOfList(T,NewN,N). buildOddList(N,InputList,L) :- ...

Constraints instead Triggers (Specific question)

I read here some reasons to use constraints instead of triggers. But I have a doubt. How can be assure (using only constraints), the coherence between SUPERCLASS tables and SUBCLASSES tables? Whit a trigger is only a matter of check when INS.. UPD... Is there a way to define that kinda relation by using only constraints (I'm newbie at ...

Error in SQL Query Alter Table MySql .

Got an error if I executed below query. ALTER TABLE property_res_details ADD CONSTRAINT PropertyIdLink FOREIGN KEY ( Property_ID ) REFERENCES properties( Property_ID ) ON DELETE CASCADE ; #1005 - Can't create table './resfi/#sql-10e1_8df.frm' (errno: 150) Please Help Me Out. ...

Can Dancing Links be applied to this CSP?

Can the Dancing Links implementation of Knuth's Algorithm X be used to solve this CSP? In this game the first and last number are always already in the board and I belive there's only one solution to each well formulated problem. ...

Specify PK name during table creation

In MSSQL is there a way to specify a name for a PK constraint so that MSSQL doesn't provide a randomly generated PK name like so: PK__Addresse__3214EC074E88ABD4 The only way I can see to do it now is to first create the table and then issue an ALTER command to rename the PK. It would be easier if I could do it in one shot. ...

Displaying the constraints in a table.

Hello I am trying to display the constraints in one of my tables but for some reason I get the message no rows selected. Noted below is the table I have created. Create table Teams ( TeamID varCHAR2(4) constraint Teams_TeamID_PK Primary Key, TeamName VARCHAR2(40) ); This is the code I am using to show my constraints. SELECT c...

Any tools or techniques for validating constraints programmatically between databases?

If you had two databases, that had two tables between them that would normally implement a one to one (or many to many) constraint but cannot since they are separate databases, how would you validate this relationship in an application or test? Is there a simple way to do this? For example, a tool or technique that can, given a constrai...

In there a generic constructor with parameter constraint in C#

In C# you can put a constraint on a generic method like: public class A { public static void <T> Method (T a) where T : new() { //...do something... } } Is there also a way to put a constraint like "there exists a constructor with a float[,] parameter?" The following code doesn't compile well: public class A { ...

How do I add Check Constraints in an AttributePropertyConvention in Fluent NHibernate?

First time journey with (Fluent) NHibernate. What I am trying to do is to add conventions for the attributes in System.ComponentModel.DataAnnotations. How would I add a Check Constraint for the attribute.MinimumLength? Here is my code so far: Thanks! using System.ComponentModel.DataAnnotations; using FluentNHibernate.Conventions; usin...

How do I DROP a constraint from a sqlite (3.6.21) table?

I have the following table: CREATE TABLE child( id INTEGER PRIMARY KEY, parent_id INTEGER CONSTRAINT parent_id REFERENCES parent(id), description TEXT); How do I drop the constraint? sqlite> ... ? ...

Constructor with an array of subclasses of an abstract class as a parameter

I'm working on a player inventory system for a game. I have a struct Slot which has a List<Loot> collection that represents which kinds of items are allowed in it. The abstract class Loot is subclassed by all items which are lootable - i.e.: would be valid Content values for the Slot struct. I want to express that a Slot can have res...

Reproducible Deadlock Using Cascading Constraints

I am looking for code to generate a reproducible deadlock that occurs from the use of Cascading Constraints. I can find references online for the specific problem, and I have answered dozens of questions on deadlocks where cascading constraints were in use, but none of them has a reproducible version of the deadlock. I am not looking fo...