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

How to create composite unique key in Hybris

Is it possible to create composite unique key in Hybris through items.xml? In the given example:
Ricardo Machado
  • 784
  • 6
  • 22
2
votes
3 answers

How to generate unique ids in react. js component

I have a render function in the component which is responsible to render a controls on page. So far it is working fine. render() { render ( {this.state.Inputs.map(input => { if (input.CODE === "VARIABLE") { return (
Nilesh
  • 518
  • 1
  • 9
  • 26
2
votes
2 answers

MySQL Key Constraint

I've got a MySQL table with, among other things, two fields: a (int) and b (string) using the InnoDB engine. I want to structure it so that a particular value of b can appear an arbitrary number of times in the table but every time it appears it …
Jesse Cohen
  • 4,010
  • 22
  • 25
2
votes
1 answer

Generate a unique access key for account setup with SQL

I'm trying to come up with an efficient way to generate/validate unique access keys for an application I'm writing. The issue I'm having is because of how the SQL database is set up. Basically, there are two tables in question. A Users table and a…
Kenta
  • 369
  • 1
  • 10
  • 30
2
votes
0 answers

2 phase commit implementation

I'm trying to implement a 2-phase commit over a document database which supports only single-phase commit using transaction info on the inserted data. I understand the theory behind 2-phase commit, but in practice there are a few obstacles. Let's…
Metheny
  • 1,112
  • 1
  • 11
  • 23
2
votes
4 answers

SQL Primary Key

I came across the 2 versions of sql code.. --1 CREATE TABLE Location ( Id INTEGER PRIMARY KEY NOT NULL, Name TEXT NOT NULL ); --2 CREATE TABLE Location ( Id INTEGER PRIMARY KEY NOT…
Eminem
  • 7,206
  • 15
  • 53
  • 95
2
votes
4 answers

Generating Random IDs for Database

I have a requirement on a project where I need to generate unique ID's. ID's must be upper case. I cannot check database to see if ID has been used previously. We expect to have many millions of records added to database every month. I have tried…
Tom Vaughan
  • 390
  • 2
  • 16
2
votes
1 answer

How to have a concatenation of string columns as unique constraint in MySQL

I have a table say employee The employee table has few fields such as `salary` `name` `age` `designation` Out of which only designation is nullable. I can't make it NOT NULL as it is being used by existing code. Is it possible to create a combined…
user9920500
  • 606
  • 7
  • 21
2
votes
1 answer

How to generate unique string from users input?

For example, user can submit $a, $b and $c. and I need to create a unique string from these inputs. If I use $uniq = $a$b$c, the input $a=AB, $b=CD, $c=EF and $a=A, $b=BCD, $c=EF both generate $uniq=ABCDEF. If I use $uniq = $a|$b|$c, then $a=AB,…
Sato
  • 8,192
  • 17
  • 60
  • 115
2
votes
1 answer

Does Hashing.crc32 generate a unique string if the hashString is a nanotime?

I'm developing an url shortener and I have to generate in java a unique string like this "3d0d1fb8", to have a short url like this: shrt.it/3d0d1fb8 I'm using this code: String nanotime = String.valueOf(System.nanoTime()); String uniqueId =…
2
votes
2 answers

Finding objects in Core Data by array attribute, performantly in >10k elements

Short: I need to find core data objects by a key, which holds a unique immutable array (fixed length, but chosen at runtime) of arbitrary objects (for which not only element membership, but also element order determines uniqueness). NSManagedObject…
Regexident
  • 29,441
  • 10
  • 93
  • 100
2
votes
2 answers

Sequelize, many unique composite keys using same field

If I am designing a table containing the following fields column_one, column_two, column_three, and I want the combination (column_one:column_two) to be unique, I would do the following: column_one: { type: DataTypes.INTEGER, unique:…
Lazarus Rising
  • 2,597
  • 7
  • 33
  • 58
2
votes
2 answers

Java code to find unique key of all the table of the database

I m trying to find all the unique key of all the table. And it would be vendor independent. Please help thanks in advance.
Kunal
  • 21
  • 1
  • 2
2
votes
1 answer

Update table with two columns as unique constraints in SQLite, NOT create table again

I want to update table in my SQLite database and add UNIQUE contraint to two columns in my Data table. Here is what I was trying , but throws error. ALTER TABLE Data ADD CONSTRAINT Data UNIQUE(id, dateofday); All previous answers are on create…
minigeek
  • 2,766
  • 1
  • 25
  • 35
2
votes
0 answers

MySQL Procedure Update Unique Column if value exists return 0 otherwise return 1

I have a table which have one primary key (phone_number), one unique column (nick). I want to write a procedure which gets phone_number and nick as input. It will update nick of row that if phone_number = in_phone_number. If nick already exists in…
Efe AYDIN
  • 193
  • 12