unique-key

What's the difference between the two DDLs in MySQL?

create table categories(a integer unsigned NOT NULL,b integer unsigned NOT NULL,primary key(a,b)); And create table categories(a integer unsigned NOT NULL,b integer unsigned NOT NULL,unique (a,b)); Are there any functional difference? ...

how can i have a unique column in many tables

hi. I have ten or more(i don't know) tables that have a column named foo with same datatype. how can i tell sql that values in all the tables should be unique. I mean If(i have value "1" in table1) I should NOT be able to have value "1" in table2 ...

Primary Key Identity Value Increments On Unique Key Constraint Violation

I have a SqlServer 2008 table which has a Primary Key (IsIdentity=Yes) and three other fields that make up a Unique Key constraint. In addition I have a store procedure that inserts a record into the table and I call the sproc via C# using a SqlConnection object. The C# sproc call works fine, however I have noticed interesting results ...

how to generate unique numbers less than 8 characters long.

hi I want to generate unique id's everytime i call methode generateCustumerId(). The generated id must be 8 characters long or less than 8 characters. This requirement is necessary because I need to store it in a data file and schema is determined to be 8 characters long for this id. Option 1 works fine. Instead of option 1, I want t...

Fastest way to compute a "Visual" checksum of an image

I'm looking to create an ID system for cataloging images. I can't use md5() since that will change if I alter the EXIF tags of the image. I am currently using the SHA1 checksum computed by imagemagick. It works perfectly, but it's really, really slow on larger images (~15 seconds on a quad-core xeon for a 21 megapixel JPG). Are t...

How to enforce unique-field validation in MVC

I am in the way building some MVC Application and I really love the Data Annotations support in MVC. The build in support is good enough to enforce simple validation checkup. I wonder, how to implement unique-field validation using custom data-annotation ? For example, I have a view model that need the user to register a new login name, ...

Unique keys in Entity Framework 4

An existing DB schema has unique, non-primary, keys, and some foreign keys that rely on them. Is it possible to define unique keys, which are not primary keys, in Entity Framework v4? How? ...

mysql ON DUPLICATE KEY UPDATE

Hi-- I'm stuck on a mySQL query using ON DUPLICATE KEY UPDATE. I'm getting the error: mySQL Error: 1062 - Duplicate entry 'hr2461809-3' for key 'fname' The table looks like this: id int(10) NOT NULL default '0', picid int(10) unsigned NOT NULL default '0', fname varchar(255) NOT NULL default '', type varchar(5) NOT NULL default...

Creating a unique key based on file content in python

I got many, many files to be uploaded to the server, and I just want a way to avoid duplicates. Thus, generating a unique and small key value from a big string seemed something that a checksum was intended to do, and hashing seemed like the evolution of that. So I was going to use hash md5 to do this. But then I read somewhere that "MD...

How do I create an index on a table that is non unique?

I want an index on a non-primary key column, but this column may have nulls in it. I find on a normal unique index, it (rightly so) only allows one null. Is that possible? and what is the syntax for this? ...

What is the difference b/w Primary Key and Unique Key

I tried to find it out in google but not satisfactory answer is given out there.Can anybody explain the solid difference. actually if Primary key is used to select data uniquely then what is the need of Unique key? when should I use a Primary key and when to use a Unique key? ...

Multiple keys/indeces/constraints when joining three tables

I'm getting more and more confused as I try to distinguish from the ambiguities of these terms. I have a query that is taking longer than necessary simply because I cannot get the key on on table to work for the other joins. I have only one column that is "Unique" in t1, there are others which are 73.8% unique and I cannot figure out h...

How Can I assign a sequence value to a sqlite field when the field UID value is NULL

Hi All, How I can assign a sequence value to a field "UID" which is NUll in existing sqlite table, for example table: FOO name UID A 1 B 2 C 100 D NULL E NULL F NULL what I want is table: FOO name UID A 1 B 2 C 100 D 101 E 102 F 103 Can some body help? I want to seek an alternative for using autoi...

Colorize Unique Elements in XML using XSLT

I currently have an XML document which basically consists of several conversations between people just like an IM conversation. I have each conversation displaying how I want to so far, except I want each name to be a unique color for readability. How I have it is that the XML is transformed into HTML with CSS. I'd like to use XPath a...

Database Design - How do I setup an FK relationship to 1 of 2 tables??

What is the best way to maintain a unique ID field across multiple database tables? My database contains both businesses and people, and both entities need to have a unique ID field associated with it. In addition, there are other tables (for example Addresses) which can reference either a business or a person using their ID as a foreig...

MySQL INSERT only if row doesn't exist, otherwise select the duplicate row.

I am looking for a statement that will try to insert a row into a table, but return the primary key of the duplicate row if one is encountered. One field in the table is the auto incrementing primary key, the other is unique. ...

symfony : how to make a validator for unique key ?

Hello, I want to know how I can make a validator for a key which must be unique. ...

AppEngine Primary Keys

Hi, by default, GAE adds a unique key to your db entries. Is it possible to have a numeric unique key in addition? Elias ...

C# What should be the UNIQUE ID of a machine? Its MotherBoard ID? Window Product ID? ??

I want to retrieve the unique ID of a machine. Like others I also did a lot research, and found none of the process of Unique ID generation works perfectly. For Motherboard Serial Number (ID): It is Unique; it cant be changed. However, it may not be found in some machines if Manufactures didn't put information on Memory Location. Then ...

Using the title of a posting as a unique identifier [Ruby/Rails]

Hi gang! I need to store a range of unique strings. For each unique string, i need to store this in the DB: ["Unique title/unique description"] -> [3][pointer_to_posting 1, pointer_to_posting 2, to_posting 3] I have a model for the posting, but i do not have a model for [unique title]. All I want to do is to store a list of questions...