constraint

Entity Frmwk pb: search for 'added' entities in current context

I'm using guids as PK for my entities. As EF doesn't support the newid() SQL statement, I force a Guid.NewGuid() in my creation methods. Here is my problem : I've a table with a clustered unique constraint (2 strings, not PK). I'm running some code in the same EF context which perfoms operations and adds/links entities, etc. Is it pos...

Is it possible to set a unique constraint as a foreign key in another table?

Is it possible to set a unique constraint as a foreign key in another table? If yes, how would you go about declaring it? How would you go about assigning a candidate key? Is it possible? Sorry, I'm a real noob at oracle. Example: I have a product table that consists of: prod_id, prod_name, prod_price, QOH Where I want prod_name to ...

Hibernate - renaming objects with a unique constraint.

Say you have a bunch of Article objects, with a "title" property. Then there's an ARTICLE table with a TITLE column. The TITLE column has a unique constraint. The UI shows all the articles on one page, with a text field for editing the title. Imagine a situation where you have two articles X & Y, X having the title "1" and Y having the...

Derby - Obtain column list of uniqueness constraint

I 'RTFM' and did not find a way to retrieve the columns involved in a unique constraint for a given schema and table. Somewhere I read that there should be an implicitly created unique index, which backs the unique constraint. Its name is supposed to be equal to the name of the conglomerate that corresponds to the unique constraint. So...

Unique Constraint on two fields and their reverse

Hello, The problem is the following, I have a table of friendships in my database, the friendship table has two foreign keys to the users table. I want to set a unique key on the two foreign keys so that I will have no duplicates, but I want more, I want that if user A added user B, then B won't be able to add A, and I want to have on...

Difficult Temporal Cross-Table Database Constraint

I have a particularly difficult business constraint that I would like to enforce at the database level. The data is financial in nature, and so must be protected from inconsistencies to the nth degree – no trusting the business layer with this stuff. I use the word "temporal" somewhat loosely, meaning that I intend to control how an enti...

Constraint - sql server

I want to add a constraint on a column that depends on a column from a different table. For example, if in table T1 I have a string column str1, and on table T2 I have a string clumn str2, I want str1 to be null except for when srt2 - "ok". ...

Looking for SQL constraint: SELECT COUNT(*) from tBoss < 2

Hi, I'd like to limit the entries in a table. Let's say in table tBoss. Is there a SQL constraint that checks how many tuples are currently in the table? Like SELECT COUNT(*) from tBoss < 2 Firebird says: Invalid token. Dynamic SQL Error. SQL error code = -104. Token unknown - line 3, column 8. SELECT. Thanks. Norbert ...

[Java] Find a Database table's unique constraint

Hi, I'm trying to find the unique constraints of a table using Java (on an Oracle Database, but that should make no difference). I found a way to discover the Primary Keys of a table, thanks to DatabaseMetaData's getPrimaryKeys(....); However I was unable to find the unique constaints of the tables, and the Internet was not able to he...

handling mysql constraint errors

Hi! I tried searching for a solution in this website but I can't seem to find any. I needed to find a way to know which field in my table is causing the constraint error.. In my table, say members table two fields (username,email) are unique keys and defined as unique keys apart from my primary key (memberid). When i add data to this t...

[Oracle] Type reference scope

Hello, I'm studying databases and am currently working on a object-relational DB project and I've encountered a small problem with the number of possible constraints in an object table. I'm using "Database Systems: The Complete Book" by Hector Garcia-Molina (and other authors) as a reference and there's a general SQL example like this: ...

Delphi: generic and type constraints

Is it possible to constrain the type of generic to, say, two different classes? Like so: TSomeClass<T: FirstClass; T: SecondClass> = class // ... end; (Sorry about the lack of formatting - the SO tool bar has disappeared from my browser). I know the above won't compile, its only written so to give you guys an idea. I tried TSomeCl...

Declaring a default constraint when creating a table

Hi, I am creating a new table in Microsoft SQL server 2000 by writing the code instead of using the GUI, I am trying to learn how to do it "the manual way". This is the code I am actually using, and it works fine: CREATE TABLE "attachments" ( "attachment_id" INT NOT NULL, "load_date" SMALLDATETIME NOT NULL, "user" VARCHAR(25) NOT NU...

How to constraint column of MySQL?

like: create table test( score integer unsigned between 1 and 100 ... ); Is it possible to do this in MySQL? ...

Restricting generic type fails in a particular situation

I like to separate my definitions from my implementations. I have an interface Entity: public interface Entity<E> where E : Entity<E> { EntityId EntityId { get; } bool ReadOnly { get; } void FailIfReadOnly(); E Copy(); } E is the actual entity type, such as Customer: public interface Customer : Entity<Customer> { }...

PostgreSql - Constraint Not Applied by a Trigger

I have a table defined like this: CREATE TABLE A ( begin date, end date, CONSTRAINT ordered_dates CHECK ( begin <= end) ) ..and 2 triggers associated : trigger1 on BEFORE update trigger2 on AFTER update In the trigger1, there's an insert in a second table B by computing the interval (=end-begin). If the constraint ordere...

RDBMS: reference constraints

Hi all, I think I have the use of reference constraints in RDBMS's a bit mixed up. Take this example for instance: Table folder Table file (with FK_folder) A file record is a child of a folder record. When I want a user to delete a folder I want to warn them if there are files located in the folder. Usually I would therefor put ...

how can I generate strings that satisfy some restrictions?

Can anyone give me a hand with techniques to generate strings that satisfy certain restrictions. For example, say I need to generate strings s and t such that length(s) < length(t) length(t) > 12 t contains at least 3 capital letters and s contains a 2 And I don't mean this particular example but some generic tec...

Modifying a function used as a column default in SQL Server

Hi, We're having an issue with a poorly coded SQL function(which works fine in live, but not in our test environment). This function is used to provide a default value in many tables, trying to ALTER the function returns a "Cannot ALTER ### because it is being referenced by object" error. Is there any way round this error message? T...

Firebird SQL: Check if notNULL constraint is set for a specific column?

I want my C# program to know if the notNULL constraint is set for a specific Firebird database column. Can it be checked dynamically, perhaps by querying the meta data? I find the Firebird documentation to be very sparse. Also, how does Firebird provide information what columns exist in a specific table? ...