constraints

What mistake am I making when creating a constraint in generics?

In asp.net 2.0 I have several "dropdowns" defined using generics (examples eye color, hair color, etc). The fields are all typical; id, text, etc. All are defined as their own classes which must implement an interface I created called ILookup. However, when I try to return a List<> of this class using: ddlEyeColor.DataSource = luMgt.Get...

UNIQUE - way to have unique rows in table ?

I have problem with unique rows in db table, now it is posible to do that: id | Name | LastName | City ------------------------------------- 1 | John | Moore | London 2 | John | Moore | London when i use UNIQUE attribute in all columns i have errors inserting second Moore even it is different Name :/ how use UNIQUE (...

How can I enforce referential integrity for optionally present uniquekeys?

We have multiple offices, and within each office there are multiple departments (some departments have employees in multiple offices). We have two existing systems that identify employees in different ways: in one, employees are identified by IDA; in the other employees are identified by IDB. In the cases where an employee is identifie...

Mapping action input variables to an array via a route, with constraints

Hi there, I am trying to map a number of querystring variables into an array that is one of the parameters for an action method. The action method is as follows: public ActionResult Index(string url, string[] generics) { //controller logic here } We can easily get MVC to bind to the variable generics by using a querystring such as...

MySQL "ON DELETE CASCADE" is too powerful

hey, following problem here: i have table with persons that have one location, if i delete the location for the location table, i don't wont to lose the assigned persons. ive a entry in the location with the id=1 and the name is: "No location". and that what I'm trying to do, but i fail! ALTER TABLE `persons` ADD CONSTRAINT `persons_i...

Foreign key constraint (complex?)

I have a table that manages virtual download folders for a site. CREATE TABLE `folder` ( # id = PK `id` int(10) unsigned NOT NULL auto_increment, # folderId = self referencing FK to id `folderId` int(10) unsigned default NULL, # siteId = FK to id in site table `siteId` int(10) unsigned NOT NULL ) Ideally I like siteId to r...

Is it a good idea to duplicate columns across tables in order to enforce check constraints?

I'm faced with a situation where I have two tables: A and B. B has a foreign key to A. A has a column "Detailed" which identifies whether or not its children in B require their "Details" section to be filled out. If I have my lean structure there is no way for me to determine if a record in B needs to have its "Details" section filled...

MySQL: Can I constraint column values in one table to values in a column in another table, by DB design only?

Example: Table "persons", Column "surname" may only contain values predefined in Table "names", Column "surnames", which would contain a collection of surnames acceptable for the purpose. Can I achieve this by design (i.e. without involving any validation code)? On a MyISAM table? No? On InnoDB? Thank you. ...

MySQL, foreign key constraint does not make any difference

I have a database, with several tables. The "main" table, called contacts, stores information about contacts, each having an id, a name etc... I also have like, 20 other tables, each representing a certain function, like staff, media ... Each of these function-tables, references the contact table, with a foreign key. I've recently ad...

Is there a way to implement constraints in Haskell's type classes?

Is there some way (any way) to implement constraints in type classes? As an example of what I'm talking about, suppose I want to implement a Group as a type class. So a type would be a group if there are three functions: class Group a where product :: a -> a -> a inverse :: a -> a identity :: a But those are not any fu...

Multiple generic methods with identical names and arguments, but different results and constraints

I'm currently rewriting parts of a custom RPC mechanism (which cannot be replaced by something else, so don't suggest that ;-) ). The arguments of a call are collected in a custom collection that uses a dictionary internally. There is a method T Get<T>(string) to retrieve a named argument. For optional arguments, I wanted to add a TryGet...

Adding foreign key constraint to 'partial' primary key in PostgreSQL

I am trying to add a foreign key constraint to a table in my PostgreSQL 8.4 database, but it is failing as the target field, though part of a multi-column primary key, is not in itself unique. The database has the following structure: Table 1 (names of primary IDs): PrimaryType, Name [Primary key = "PrimaryType"] Table 2 (names of c...

A way to add a constraint between two domains in a table without using a trigger?

I have a following table, Client. create table Client ( ClientID int identity primary key, TaxID varchar(12), SSN varchar(12) ) GO Client can have either TaxID or SSN or both. But either one should exist. Currently, I am enforcing the rule thru following trigger. create trigger trgClient_UniqueTaxIDSSN ...

Upgrading FParsec: upgrade discriminated unions to satisfy the new equality/comparison constraints

So, by a hilarious series of events, I downloaded the FParsec source and tried to build it. Unfortunately, it's not compatible with the new 1.9.9.9. I fixed the easy problems, but there are a couple of discriminated unions that still don't work. Specifically, Don Syme's post explains that discriminated unions containing items of type ob...

MS Access 2003 - Performing Calculations in a table's field with Transactions Table

One thing I want to do is build a personal database for myself at home to use a financial database (transaction log, checking/savings account tables, etc), and I want to do this mainly to learn more about developing databases. I am pretty familiary with MS Access, though not put to use in this context, but what I am really trying to lear...

SQL Server Check Contraint and checking Signed In/Out state

I have a table that functions as an event log and stores the users signed in state, 'In', 'Out', or 'Rejected' (sometimes users my be 'Rejected' based on external criteria). Here is some sample data so you can get an idea of what the table looks like: Table MyTable PersonID - State - DateTime // data sample 156 - 'Out' ...

Unique XML element constraint in T-SQL

Hi, I have an SQL (Microsoft SQL 2008) table with XML data in one of the columns. Each XML root node has an attribute which is a GUID. For example: <!--Row 1--> <example:root id="E0B1BCEA-C0E2-4d7c-BF67-FA9A7C3FBA73"> [...] </example:root> <!--Row 2--> <example:root id="13BB87F4-32A5-4de7-8CE9-E62AF002B958"> [...] </example:r...

Constraint on subtype attribute (Oracle)

If i have a type x_typ and subtype y_typ, is it possible to create a an object table of x_typ but put a constraint on one of the y_typ attributes i.e. create table x_table of x_typ ( constraint constr_y check (y_typ.attribute1 < 5); ); Thanks ...

Checking if some function parameters data types are equal due compilation on C#

Hi, I have some example data: public struct Task { public int INT; public string STRING; public DateTime? NULLABLEDATETIME; } And function, which uses it: public KeyValuePair<Expression<Func<Task, object>>, object> Marry(Expression<Func<Task, object>> key, object value) { return new KeyValuePair<Expression<Func<Task, ...

How scala generic constraints to nullable types work

I've tried two ways to constrain a generic type parameter to a nullable type, but both seem to have some unexpected problems. First attempt (using T <: AnyRef): scala> def testAnyRefConstraint[T <: AnyRef](option:Option[T]):T = { | //without the cast, fails with compiler error: | // "found: Null(null) required: T" | o...