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
-1
votes
2 answers

How to generate 10 digit unique-id in python?

I want to generate 10 digit unique-id in python. I have tried below methods but no-one worked get_random_string(10) -> It generate random string which has probability of collision str(uuid.uuid4())[:10] -> Since I am taking a prefix only, it also…
SHIVAM JINDAL
  • 2,844
  • 1
  • 17
  • 34
-1
votes
1 answer

Symmetric DS different PK but same unique resolution

We have this MySQL table: id BINARY PRIMARY KEY, -- this is actually GUID position INT NOT NULL UNIQUE some_value VARCHAR(200) On each of two nodes, users create a new entry but with the same position: id=0x01 position=5 some_value = "first node…
-1
votes
1 answer

Encountered two children with the same key - item duplication

i have multi language page in nextjs. i want to change language by clicking dropdown. const language = [ { locales: 'fa', name: 'فارسی', country_code: 'ir' }, { locales: 'en', name: 'English', country_code: 'gb' }, …
alireza
  • 83
  • 2
  • 9
-1
votes
1 answer

How can I recognize the guest user after they signup?

Is there anyway I can assign uniqueId to the guestUser when they landup on my website and then once they signup I can recognize that User with the uniqueId?
-1
votes
2 answers

Unique ID Generation From DB value with 11 digits using Java causing Unique constraint exception

I have a requirement where we need to generate unqiue block ID which will be 11 characters. We have below logic to generate it, public String generateBlockId(){ boolean alreadyExists = true; String newBlockId = ""; …
vasantharajan
  • 265
  • 5
  • 18
-1
votes
1 answer

How to add a unique constraint such that one of my field in my table should checks the uniqueness only based on the another field in my table

My table name: Records Fields: School_id, Admission_id Association: class Record < ActiveRecord::Base belongs_to :school For example So i need to have a made an uniqueness such that admission id should be unique on school alone, different school…
jegan
  • 31
  • 7
-1
votes
1 answer

Java algorithm to create own unique key

I want to create an own unique key which is 6 characters long and includes the following regex characters and numbers: [a-z][0-9] e.g.: 00000A, 00000B, ... 00000Z, 00001A, 00001B,... I don't know how to create this algorithm of these regex…
-1
votes
1 answer

how to generate automatic transaction code with Laravel 7 with format : [code-date-sequence] LIKE: PSN-22102021-001

I want to generate a unique transaction code with using date an example: PSN-22102021-001 or PSN-22102021001, how to do it?
-1
votes
4 answers

SQL Server unique vs not unique index INSERT performance

I would like to create a covering index to improve query performance. I do know that this one more index will impact INSERT performance. The table has only INSERT operations no UPDATE or DELETE. The data in covering index will unique because the…
g.pickardou
  • 32,346
  • 36
  • 123
  • 268
-1
votes
2 answers

Unique table constraint

I have a table as follows: CREATE TABLE `b` ( `b1` int(11) DEFAULT NULL, `b2` int(11) DEFAULT NULL, UNIQUE KEY `b1` (`b1`,`b2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 Here, the unique table constraint is given for 2 fields. But, in the show…
user14151025
-1
votes
1 answer

MySQL Clone matching rows and amend one field with unique PHP generated value

I'd like to clone all the rows that have YEAR=2020, and assign the GAMECODE field to be the value generated by the php function. However at the moment that gamecode is only generated once so I am getting a "Duplicate entry" error. $number =…
onlybarca6
  • 35
  • 4
-1
votes
1 answer

AWS kms.generateRandom in a lambda function does not work

I am trying to generate a random key in a lambda using kms.generateRandom. I tried the sample mentioned in the document but it does not return anything. No error no Data. Has anybody used it? Do I have to grant any access to my lambda? Below is the…
-1
votes
1 answer

I Cant Solve The Issue With Primary Key And Unique Key On Mysql DB

please before vote down, read the full questions. OK.. now i am trying to import data from access to mysql db. on my access file data look likes: a) Structure: you can see there ID as the primary Key, and MGenre is the Unique key b) Data: as you…
Zakir_SZH
  • 466
  • 7
  • 21
-1
votes
2 answers

what is the convention for normalizing a table with many primary keys

I have a database table like so : col1 PRI col2 PRI col3 PRI col4 PRI col5 PRI col6 col7 col8 So, it looks like all the columns from 1 to 5 need to be unique and that it makes 'sense' to just make those keys primary. Is this the right way of…
-1
votes
1 answer

In SQL Server, can we compare null values in Foreign Key in onetable and Unique Key in other table?

Foreign Key and Unique Key can have null values right .Suppose FK in Table1 references UK in Table2, can we compare null = null , or such comaprisons will be skipped? Unique key can take 1 NULL value, hence the question. Adding the example as…
Vipin
  • 9
  • 1