constraints

Lowercase constraint - Sql Server

I'm not sure if this should be a constraint or not, but I want the "UserName" column of a table to ignore the value that is set when an insert or update is executed and instead, store the value of "DisplayUserName" column converted to lowercase. And if "DisplayUserName" is changed, "UserName" should be updated as well to "DisplayUserName...

Best way to enforce inter-table constraints inside database

I looking for the best way to check for inter-table constraints an step forward of foreing keys. For instance, to check if a date child record value is between a range date on two parent rows columns. For instance: Parent table ID DATE_MIN DATE_MAX ----- ---------- ---------- 1 01/01/2009 01/03/2009 ... Child table PARENT_ID...

Prevent insertion of repeated information in SQL.

Is there a quick way to prevent insertion of repeated data into a table? I mean, the key will always be different but the rest of the entry could be repeated and by so, there would be 2+ different keys identifying the same data. I could search the whole table but i am afraid of the performance lost when doing this. Note: I'm just start...

requiring the presence of static methods in C#

Given a group of objects that have a common set of properties and methods in support of given domain logic, is there a way of enforcing the presence of certain static methods on these objects? I have concluded that implementing an interface does not achieve this (methods are instance only) and that static methods can not be marked overr...

What happens when I drop a clustered primary key in SQL 2005

I've a PK constraint - a clustered index on two columns - which I am in the process of dropping. The command is still running after an hour. I would have thought that as I am just removing a constraint the operation would be nearly instantaneous. Can someone explain to me what is actually happening under the hood when I drop the PK? ...

MySQL and Check Constraints

I have inherited an application that uses MySQL and that is used by a PHP front end. The guy that wrote this system has gone to some fairly convoluted lengths to ensure that codes that users enter are valid - and tat means that these codes also exist in another table. When I first saw this I wondered why he hadn't used CHECK constraints...

Generic constraint to ValueTypes, Strings and Nullable of ValueTypes

I'm trying to add a constraint to a generic method so it checks for ValueTypes, Strings or Nullable value types. The problem is that: value types are struts strings are immutable reference types nullable are value types but won't be accepted in a "where S : struct" type constraint. So does anybody know if there's a way I can accep...

Turn off constraints temporarily

I'm looking the way to temporarily turn off all DB's constraints (eg table relationships) I need to copy (using INSERTs) one DBs tables to another DB I know I can archive that by executing commands in proper order (to do not break relationships) But it would be easier if I could turn off checking constraints temporarily and turn on it...

Question(s) on implementing check constraints with SQL CLR integration.

I'm implementing 'check' constraints that simply call a CLR function for each constrained column. Each CLR function is one or two lines of code that attempts to construct an instance of the user-defined C# data class associated with that column. For example, a "Score" class has a constructor which throws a meaningful error message when...

detecting conflicts in recurring events

Hello all I'm writing a calendar application that needs to check for conflicts between recurring entries. Each Entry object has a recurrences() method which returns an array of ranges - each range contains the start and end times of each future occurrence. I need to check for conflicts between new and existing entries. I'm doing this b...

What is the best way to handle this constraint in SQL Server 2005?

I have SMS based survey application which takes in a survey domain, and a answer. I've gotten requests for detailed DDL, so.... The database looks like this SurveyAnswer.Answer must be unique within all active Surveys for that SurveyDomain. In SQL terms, this should always return 0..1 rows: select * from survey s, surveyanswer sa wh...

Implementing variable constraints in C++

I've been looking for an example that shows how to implement constraints in C++ (or a boost library that lets me do this easily), but without much luck. The best I could come up with off the top of my head is: #include <boost/function.hpp> #include <boost/lambda/lambda.hpp> template<typename T> class constrained { public: cons...

Constraint for one-to-many relationship

We have a two tables with a one-to-many relationship. We would like to enforce a constraint that at least one child record exist for a given parent record. Is this possible? If not, would you change the schema a bit more complex to support such a constraint? If so how would you do it? Edit: I'm using SQL Server 2005 ...

Removing the CENTER element from a JPanel using BorderLayout

Is there any way of removing the Component added to the CENTER of a JPanel with a BorderLayout, without having to reference the Component itself? ...

How can I drop all the default constraints constraints on a table

Hi All, How can I drop all the default constraints belonging to a particular table in SQL 2005? ...

What to do when I want to use database constraints but only mark as deleted instead of deleting?

I am working in a project where database items are not deleted, but only marked as deleted. Something like this: id name deleted --- ------- -------- 1 Thingy1 0 2 Thingy2 0 3 Thingy3 0 I would like to be able to define something like a UNIQUE constraint on the name column. Seems easy, right? Let's imagine a scena...

How to query any constraint's target list without knowing the constraint type?

In Maya, I have a list of constraints gathered by the following code. I want to iterate the constraints and query the targets for each of them: cons = ls(type='constraint') for con in cons: targets = constraint(query=True, targetList=True) The problem, there is no general constraint command for manipulating all constraints. Inste...

Migrating DB: Keep relations constraints?

At the risk of being called a fool, I am wondering what your thoughts are on maintaining relationship constraints within a MS SQL DB. I am migrating a system into a .NET environment from ASP. This brings with it business objects and other tiered-coding techniques, which work to abstract the database from the user/API. The new applicatio...

MySQL Removing Some Foreign keys

I have a table whose primary key is used in several other tables and has several foreign keys to other tables. CREATE TABLE location ( locationID INT NOT NULL AUTO_INCREMENT PRIMARY KEY ... ) ENGINE = InnoDB; CREATE TABLE assignment ( assignmentID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, locationID INT NOT NULL, FOREIGN...

MySql NOT NULL Constraint doesnot work

I am trying to implement NOT NULL constraint in the customer table which is created as: CREATE TABLE CUSTOMER( cust_id INT(5) NOT NULL AUTO_INCREMENT, PRIMARY KEY(cust_id), first_name VARCHAR(25) NOT NULL, last_name VARCHAR(25) NOT NULL, email VARCHAR(25) NOT NULL, password VARCHAR(25) NOT NULL, gende...