constraints

TSQL Constraints on Temp Tables

Very quick and simple question. I am running a script to import data and have declared a temp table and applied check constraints to that table. Obviously if the script is run more than once I check whether the temp table already exists and if so, I drop and recreate the temp table. would that also drop and recreate the check constraints...

Is it possible to constrain an auto-incrementing primary key with artificial limits?

Can an auto-incrementing primary key be constrained by artificial limits? For example if I only want integer primary keys to be from a specific range of integers, say between 100 and 999 inclusive, and auto-increment, is that possible? And if so, on which database server software. I'm mainly interested in MS SQL Server 2000 or greater bu...

ElevateDB relational model do’s and dont’s

My company uses ElevateDB in one of our products. However, our database is just a bunch of tables. Recently, as more features are designed and more modules are added, we have found out our data is no longer “bunch of unrelated tables”, but it begins to be real data structure. I have no previous experience with ElevateDB, I worked with O...

iPhone Platform Constraints

Hello, I'm analyzing the iPhone platform (for a paper). I've made a list with issues, developers/architects have to consider, before working with the iPhone SDK. The questions aims at people, who want to release iPhone software. What constraints restrict them in comparsion to other mobile platforms, such as Android, Windows Mobile, S...

How to specify a list of choices in XSD

I have an XSD definition that has a list of tagged elements. In what way is it possible to allow developer's to only select from a list of elements already defined in the XML file when entering values for a choice-restricted element? In other words, given this XML declaration: <collection> <myItem name="Item_1"> <childEle...

Use size constraint with Integer in Grails

The reference doc says that the size constraint: "Uses a Groovy range to restrict the size of a collection or number or the length of a String." When I put a size constraint on an integer, I get a warning "Property [prop] of domain class TheClass has type [java.lang.Integer] and doesn't support constraint [size]. This constraint will n...

Curiously Recurring Template Pattern and generics constraints (C#)

I would like to create a method in a base generic class to return a specialized collection of derived objects and perform some operations on them, like in the following example: using System; using System.Collections.Generic; namespace test { class Base<T> { public static List<T> DoSomething() { List<T> object...

Postgresql constraint changes

I added a constraint to a Postgres table, but when I do "\d tablename" the constraint doesn't show up. How do I see what the constraints are? I'm sure this is a very basic thing, but I can't find the answer! EDIT: the constraint does actually exist and work. EDIT: first response now shows how constraint can be found using information_...

Unique constraint that allows empty values in MySQL

I have a field that stores product codes. The codes are unique, but some products simply doesn't have a code. I can't invent codes because those are providers codes. Is this kind of constraint possible in MySQL? I'm a noob with stored procedures and triggers, so if the solution involves one of these, please be patient. Update: The col...

Is there a C# generic constraint for "real number" types?

Greets! I'm attempting to set up a Cartesian coordinate system in C#, but I don't want to restrict myself to any one numerical type for my coordinate values. Sometimes they could be integers, and other times they could be rational numbers, depending on context. This screams "generic class" to me, but I'm stumped as to how to constrict...

Can I put constraint on column without referring to another table?

I have a text column that should only have 1 of 3 possible strings. To put a constraint on it, I would have to reference another table. Can I instead put the values of the constraint directly on the column without referring to another table? ...

Fluent NHibernate primary key constraint naming conventions

Is there any way to create a naming convention for my primary key constraints in Fluent NHibernate? I know you can name foreign key constraints, but it does not appear possible to name the primary key constraint. ...

Java Constraints Library (JCL) problem: how to represent addition?

I have to solve a CSP logic problem using Java Constraints Library. For now I've managed to represent some constraints of the problem, most of them are based on "equals" and "not equals" binary constraints. My doubt is, how to represent an addition based constraint? Example: variable1 belongs to DomainA variable2 belongs to DomainB var...

Odd behaviour with generic Constraints on an Extension method

I must be doing something wrong here (because really, what are the chances of me tripping over another bug in the Vb.net compiler?) I have a static generic function in .net 2.0 Vb code, I thought it was time to "upgrade" it to be an extension method, but the compiler complains with Extension method 'AddIfUnqiue' has type constrai...

How do I update a constraint on my CALayer?

I have a CATextLayer that I want to be able to vertically align within my view. I can set a constraint to align it to the top of the view, to the middle, or to the bottom; but I want to be able to allow the user to change this on the fly. When I set up my CATextLayer, I use this constraint to align it in the middle: [textLayer addCons...

How can I disable a constraint?

I have a constraint (named INVS_ITEM_LOCATIONS_PK) in my SQL Server 2005 table. How can I disable it? ...

C# - how to create an inherited generic collection from a factory method

I am trying to write a factory method that will create a derived instance of an abstract generic collection class. Here are the base classes ... abstract class ItemBase { } abstract class CollectionBase<T> : Collection<T> where T : ItemBase, new() { } ...and their derived classes ... class Item : ItemBase { } class ItemCollection :...

How to model simple scheduling problem using MS Solver Foundation?

I have the following simple problem that I'd like to use to experiment with MS Solver Foundation: I have a schedule where I need to have 2 workers per day for 30 days. I need to honor the following constraints: No people should work two days in a row. Unless a special exception is applied, people should only work once per week. Some ...

What is the purpose of constraint naming

What is the purpose of naming your constraints (unique, primary key, foreign key)? Say I have a table which is using natural keys as a primary key: CREATE TABLE Order ( LoginName VARCHAR(50) NOT NULL, ProductName VARCHAR(50) NOT NULL, NumberOrdered INT NOT NULL, OrderDateTime DATETIME ...

Can there be constraints with the same name in a DB?

This is a follow-on question from the one I asked here. Can constraints in a DB have the same name? Say I have: CREATE TABLE Employer ( EmployerCode VARCHAR(20) PRIMARY KEY, Address VARCHAR(100) NULL ) CREATE TABLE Employee ( EmployeeID INT PRIMARY KEY, EmployerCode VARCHAR(20) N...