Questions tagged [unique-constraint]

Unique-constraint is an index that sets one or multiple fields to be unique in a data entity

1353 questions
0
votes
2 answers

How to enforce uniqueness of column on nested attributes:

Lets say I had the following setup class User < ActiveRecord::Base has_many :address accepts_nested_attributes_for :address, allow_destroy: true end class Address < ActiveRecord::Base attr_accessible :house_color,…
Abraham P
  • 15,029
  • 13
  • 58
  • 126
0
votes
1 answer

Will the real unique index please stand up?

I recently encountered a DB2 table that has three different indexes that are unique. Index 1 (Columns: A, B, C) Index 2 (Columns: A, B, C, D) Index 3 (Columns: A, B, C, D, E) Is the most specific one the actual unique index? Or does the definition…
Jeff B
  • 8,572
  • 17
  • 61
  • 140
0
votes
3 answers

How to set unique constraint in Sql Server 2008

Possible Duplicate: SQL Server 2005 How Create a Unique Constraint? Add unique constraint in SQL Server 2008 GUI? I have a table in Sql Server 2008 named customer.To the email field I want to add a unique constraint-so that email should not be…
dany
  • 1,801
  • 7
  • 27
  • 40
0
votes
1 answer

Drupal 7 node_save Integrity constraint violation

I have to update some nodereference fields from custom code in myModule. This has to be done when a new node of a particular type is being inserted so I implemented hook_node_insert as follows: function myModule_node_insert($node){ $settings =…
sisko
  • 9,604
  • 20
  • 67
  • 139
0
votes
1 answer

sql DROP CONSTRAINT UNIQUE not working

I got the following table: CREATE TABLE `unsub_counts` ( `count_id` int(11) NOT NULL AUTO_INCREMENT, `unsub_date` date DEFAULT NULL, `unsub_count` int(11) DEFAULT NULL, `store_id` smallint(5) DEFAULT NULL, PRIMARY KEY (`count_id`), UNIQUE KEY…
axel wolf
  • 1,446
  • 3
  • 18
  • 29
0
votes
1 answer

Unique constraint over two tables

I have two tables: Country : has ID, Name State : has ID, Name, CountryID I defined Country.Name as unique. I also want to define State.Name as unique per country - i.e. I can't just define it as unique because two countries may have the same…
Bobby B
  • 2,287
  • 2
  • 24
  • 47
0
votes
2 answers

MySQL UNIQUE Constraint multiple columns condition

Well, i have a table with 4 columns(id, event_id, group_id, isbn), where id is PK, event_id and group_id are FK's, and my problem is: I need the isbn number to be unique for each event_id, let me give you some examples of some rows that should be…
Murilo
  • 580
  • 5
  • 21
0
votes
1 answer

Setting to cause php error on duplicate entry attempt to unique fields?

In our PHP application, currently mysql query errors (syntax errors, duplicate entry errors for unique keys) are not throwing PHP errors, and script execution is continuing, which is fine. I just want to know what setting (if it can be controlled…
Sandeepan Nath
  • 9,966
  • 17
  • 86
  • 144
0
votes
0 answers

MySQL - How does unique key constraint work?

table :employee Fields: eid(primary key ), empno(unique key), empname here the empNo is manually generated in the code for Ex. Accounts001.. when 2 users enter employee data with 0 time difference. During 'Add' the emp num generated for both the…
Archana
  • 53
  • 1
  • 9
0
votes
1 answer

Creating a unique column in SQL Azure Federation

I'm trying to create a unique column in SQL Azure Federation, but even though the following query creates a table, I'm still able to save entries to the table with the same Column1 value. What's the correct way to set up a unique column? I need to…
Mark13426
  • 2,569
  • 6
  • 41
  • 75
0
votes
1 answer

Create a table with a primary key and a separate unique column in SQL Azure Federation

How could I create a uniqueidentifier ID column and a unique nvarchar(256) email address column in SQL Azure Federation? I'm not a SQL guy, so I don't know how to set a unique constraint or if it's possible to do that in a federated database.…
Mark13426
  • 2,569
  • 6
  • 41
  • 75
0
votes
0 answers

How to create unique constraint on 4 fields grouped 2 and 2?

I am trying to create a relations system in my web application which will rely on a single join table defined as CREATE TABLE associations ( associationId SERIAL PRIMARY KEY, fromTable varchar(255), fromId int, toTable varchar(255), toId…
Matteo Tassinari
  • 18,121
  • 8
  • 60
  • 81
0
votes
2 answers

"on duplicate key update" with multi-field key

According to the docs: If [columns a and b are] unique, the INSERT is equivalent to this UPDATE statement instead: UPDATE table SET c=c+1 WHERE a=1 OR b=2 LIMIT 1; If a=1 OR b=2 matches several rows, only one row is updated. In general, you…
Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
0
votes
2 answers

Inserting data without duplicates

I'm trying to insert some data without duplicates, possibly from 2+ concurrent processes. Unfortunately I cannot use unique constraint in this case due to the database design (deleted rows are marked with deleted=1 and those can exist as…
viraptor
  • 33,322
  • 10
  • 107
  • 191
0
votes
2 answers

Grails Unique Constraint

I have a grails application using hibernate.Under grails 1.3.7 everything works properly, but when I switch to grails 2.0.3 the following problem appears: I can't check for unique fields under java/src directory. If I try to add or update any record…
Georgian Citizen
  • 3,727
  • 6
  • 38
  • 46