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
6
votes
1 answer

In Cassandra, if I run a query that increments a counter, then selects from that counter is that atomic?

If I run a query that increments a counter, then selects from that counter is that atomic? I am wanting to generate smaller (integer) numbers using Cassandra. The usage will likely be generating fewer than 1000 Ids/day, but definitely needs to be…
Tracker1
  • 19,103
  • 12
  • 80
  • 106
6
votes
2 answers

MySQL unique column string

Currently I have this table in my database: CREATE TABLE `twMCUserDB` ( `id` int(11) NOT NULL AUTO_INCREMENT, `mc_userName` text NOT NULL, `mc_userPass` text NOT NULL, `tw_userName` text NOT NULL, `tw_userPass` text NOT NULL, PRIMARY KEY…
Mathlight
  • 6,436
  • 17
  • 62
  • 107
6
votes
2 answers

Django & South: Custom field methods are not executed when doing obj.save() in a data migration

In my Django model I have two fields, name (a regular CharField) and slug, a custom field that generates the slug based on a field name passed in the field definition, in this case I use name for this. First, the model only had the name field, with…
5
votes
5 answers

how to get PC unique id?

What is the PC unique ID? How could we get the PC unqiue ID? Is it about Hard disk or motherboard? I'd like to store PC ID in my window program. Please share me.
soclose
  • 2,773
  • 12
  • 51
  • 60
5
votes
2 answers

MyISAM unique keys being cut off at 64 bytes, causing collisions

I've got a MySQL table that stores urls as unique keys. I'm starting to get collisions on my keys because it seems the keys themselves are only the first 64 bytes (or characters if you prefer, its a latin-1 collated) of any url. So if a url is over…
Will Olbrys
  • 957
  • 2
  • 9
  • 13
5
votes
2 answers

How to make empty string as null value to allow duplicate empty strings in optional field?

I have an email field that's optional. The regex works fine accepting the empty string (^$) but now the issue is that the empty string is considered a unique entry. It will only allow one user to register without entering an email address. I know I…
Yuck Fou
  • 61
  • 2
  • 11
5
votes
1 answer

How to add a unique index on an embedded array in Mongo DB collection

I am trying to create unique index on scorecardList.filename field in below mentioned mongo collection. The purpose is we should not be able to create another element in scorecardList with same filename. Mongo Schema: { "Name": "Ravikant…
5
votes
1 answer

Solr 5.1.0: How to set the unique key via Schema API

In Solr 5.1.0, is it possible to set the unique key via the REST schema api? I created a collection with the data driven schema. Solr would guess what the field type and create the field based on the data I upload. I can still define fields…
Chen Sheng-Lun
  • 167
  • 1
  • 7
5
votes
1 answer

jpa composite primary key and jointable with unique key

here are the sql tables: option primary key is name + value CREATE TABLE `option` ( id int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) NOT NULL, `value` varchar(45) NOT NULL, PRIMARY KEY (`name`, `value`), UNIQUE KEY `id_UNIQUE`…
user1800633
  • 59
  • 1
  • 3
5
votes
3 answers

how to generate unique id in php based on current data and time?

I need to generate a unique ID in php based on current date and time to keep a log of when i am running code. i.e. every time i run the code it should be able to generate a unique id based on current date and time. Hope I am clear with my ques. How…
user1518659
  • 2,198
  • 9
  • 29
  • 40
5
votes
1 answer

MySQL Duplicate entry for key on UPDATE

I have a unique index on a column named label, but for some strange reason why I try and do an update like: UPDATE books SET label = 'foo bar', title = 'something new', modified = UTC_TIMESTAMP(); And there already exists a row with label = 'foo…
Justin
  • 42,716
  • 77
  • 201
  • 296
4
votes
1 answer

SQL Server ignore_dup_key on apparently ignored for merge statement

SQL Server 2008. I have few pieces of code working together and the effect is rather strange so I decided to share. I have a table with emails - for simplicity let as assume there are 2 columns: ID identity(1,1) int primary key email…
nimdil
  • 1,361
  • 10
  • 20
4
votes
2 answers

GUID + Auto-Increment ID = Slow Performance?

One of Jeff Atwood's cons of using a GUID is that it is Cumbersome to debug (where userid='{BAE7DF4-DDF-3RG-5TY3E3RF456AS10}') And I agree. I was thinking, now that 16-byte ID's are no longer considered an enormous undertaking, are 16-byte + 4-byte…
yurisich
  • 6,991
  • 7
  • 42
  • 63
4
votes
3 answers

How do I create a serializer that reuses a unique key of my model?

I'm using Python 3.7, Django 2.2, the Django rest framework, and pytest. I have the following model, in which I want to re-use an existing model if it exists by its unique key ... class CoopTypeManager(models.Manager): def…
Dave
  • 15,639
  • 133
  • 442
  • 830
4
votes
3 answers

How can I create a unique key and use it to send data in Firebase?

I'm using Firebase in my project and I was trying to create a unique key using Firebase. Using this key I wanna send posts when user start the activity. Like this: "Posts" | -> "Parent Unique key" | ->…
Mattwalk
  • 139
  • 1
  • 3
  • 13