Questions tagged [unique-key]

A key is a set of attributes that is irreducibly unique and non-nullable within a table.

A key is a set of attributes that is irreducibly unique and non-nullable within a table. Irreducible means that all the attributes of the key are necessary to guarantee uniqueness - remove any one attribute and the uniqueness property would be lost. A key may consist of zero, one or more attributes and a relational table (relation variable) must have at least one key and may have more than one.

Keys are unique by definition so the commonly used term "unique key" is actually a tautology.

515 questions
10
votes
3 answers

Filter unique values from a JSON

I am using angularjs for my page. I want to filter the values from the JSON object, So that no redundancy exists. But I didn't find any way to get the unique values from angular ng-repeat. Is there anyway to do that? Ok, Here is some description…
anilCSE
  • 2,461
  • 3
  • 23
  • 29
9
votes
1 answer

Fluent NHibernate 3 uniquekey custom constraint name

I am trying to give a custom Unique Constraint Name as follows: Map(x => x.Name).UniqueKey("MY_CONSTRAINT_NAME").Column("FUNCTION_NAME"); The Field is mapped with a unique constraint but the constraint name is self-managed and doesn't take the name…
user756037
  • 285
  • 1
  • 8
  • 20
9
votes
5 answers

How can I enforce a constraint only if a column is not null in Postgresql?

I would like a solution to enforce a constraint only if a column is not null. I can't seem to find a way to do this in the documentation. create table mytable( table_identifier_a INTEGER, table_identifier_b INTEGER, table_value1,...) Do to…
Sheldon Ross
  • 5,364
  • 7
  • 31
  • 37
9
votes
3 answers

Can a unique key ( not a primary key) be a foreign key to other table?

I have two table students and studentsprofilepic 'username' from students is unique key of the table it is referenced as foreign key for the 'studentsprofilepic' table the DDL for the tables are CREATE TABLE students ( id NUMBER, …
Kamlesh Sharma
  • 222
  • 1
  • 7
  • 23
8
votes
2 answers

MySQL truncates composed unique index to 64 characters

I'm having problems with MySQL composed unique key. It consists of URL, integer value and date field. But when I try to insert row, I get an exception: Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate…
kma8794
  • 306
  • 3
  • 6
8
votes
4 answers

SQL Server 2005 unique key with null value

I have a table in SQL Server 2005 with a foreign key, and I want that foreign key to be a unique value or null. I've set it up as a unique key, but it won't allow me to have multiple nulls in the same table. Is it possible to do what I want?
Curtis
  • 475
  • 2
  • 14
  • 20
8
votes
5 answers

Add new keys to a dictionary while incrementing existing values

I am processing a CSV file and counting the unique values of column 4. So far I have coded this three ways. One uses "if key in dictionary", the second traps the KeyError and the third uses "DefaultDictionary". For example (where x[3] is the value…
Count Boxer
  • 673
  • 3
  • 11
  • 25
7
votes
3 answers

Unique System ID in Ruby ...?

Is there a way to generate an unique Hardware dependent Identification key in Ruby...?
7
votes
2 answers

Pros/Cons of and ways to implement globally unique identifier in relational database?

Regarding the first part of my question: I was recently asking myself what are the benefits and trade-offs of having a unique identifier for certain tables in a relational database. Just as an example, the Facebook (FB) Graph API allows to fetch…
7
votes
1 answer

Why can I not set this unique constraint in PostgreSQL?

I keep getting: SQL error: ERROR: could not create unique index "service_import_checksum_key" DETAIL: Key (checksum)=() is duplicated. In statement: ALTER TABLE "public"."service_import" ADD CONSTRAINT "service_import_checksum_key" UNIQUE…
KatDevsGames
  • 1,109
  • 10
  • 21
7
votes
3 answers

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…
cregox
  • 17,674
  • 15
  • 85
  • 116
7
votes
1 answer

How do I generate a session ID in Node.js?

Im trying to learn Node.js without using any third party modules or frameworks. I'm getting to the point where I got to figure out how to give session ids to users who login... So far I know I can set the session id by writing it in the headers,…
user3658794
  • 699
  • 4
  • 12
  • 19
6
votes
3 answers

Unique key on whole mysql table?

Suppose I have a mysql table with two columns: A and B. Is it possible to have a unique key so that I can only insert a value only once in either A or B (once in the whole table)? So if column A contains 'qwe' and B contains 'asd' then these two…
atlau
  • 881
  • 1
  • 7
  • 16
6
votes
2 answers

MySQL two-column unique key

I know that i can make two columns unique keys, but that's not exactly what i want. I want that for example if col1='1', col2='2' then there can't be another row with col1='1', col2='2', but totally possible to do the…
GDavid
  • 128
  • 1
  • 2
  • 12
6
votes
3 answers

Math question regarding Python's uuid4

I'm not great with statistical mathematics, etc. I've been wondering, if I use the following: import uuid unique_str = str(uuid.uuid4()) double_str = ''.join([str(uuid.uuid4()), str(uuid.uuid4())]) Is double_str string squared as unique as…
orokusaki
  • 55,146
  • 59
  • 179
  • 257
1 2
3
34 35