Questions tagged [primary-key-design]

83 questions
3
votes
4 answers

Why does an SQL table have multiple primary keys?

On my job (non programming job that takes advantage of some of my programming skills), I was asked to generate a report from our outsourced, custom made program's SQL database. When looking at the tables I see that many of them have multiple fields…
Ziv
  • 2,755
  • 5
  • 30
  • 42
3
votes
1 answer

DynamoDB primarykey timestamp

iam trying to query a dataset in dynamodb where the primary key is a timestamp. First i wanted to get all data for a specific sensorId. I tried with a scan (scan.json): { "sensorId": { "AttributeValueList": [{ "S": "1234" }], …
Khan
  • 1,418
  • 1
  • 25
  • 49
3
votes
2 answers

Hibernate get next ID with string prefix

I have one question regarding primary key generation in Hibernate. I'm working in maintaining existing registry system. Current design use string as a primary key. The rule is something like "EXE" + max(). Below is how the table look…
3
votes
1 answer

PK generation performance: DB generated sequence or app-generated random

I am trying to understand if it's more performant for a database to manage id/sequence generation for use as a PK or to have an application simply generate it's own ID as, say a random 64-bit number. My suspicion is that application + random…
Christian Bongiorno
  • 5,150
  • 3
  • 38
  • 76
3
votes
2 answers

Does HBase support indexing on list properties and non-equality operators?

Have a background in GAE's Big Table. From what I have read, HBase is the open source version of Big Table and should be very comparable in its features. Using Big Table, this object could be indexed and queried in Olog(n) time: Object widget{ …
Chris Dutrow
  • 48,402
  • 65
  • 188
  • 258
3
votes
4 answers

Reorder composition of composite primary key

I have a table documents ( year int not null, number int not null, document_types_id int not null, ... ) The primary key is year + number + document_types_id. I think that a better primary key would be year + document_types_id +…
2
votes
4 answers

Key DataType for a high volume SQL Server 2008?

I in the process of designing a database for high volume data and I was wondering what datatype to use for the primary keys? There will be table partitioning and the database will ultimatley be clustered and will be hot failover to alternative…
littlegeek
2
votes
2 answers

Database design: Primary key from multiple data sources

Initially I was importing foods from an excel document from Food Source 1 and it had VARCHAR type primary*(PK example #FOOD0001)* (Because there was only 1 source at the time I just imported directly into the foods table with auto incrementing int…
DotnetShadow
  • 748
  • 1
  • 10
  • 28
2
votes
0 answers

REST API Primary Key Design MySQL

We're building a new REST API and have a few decisions to make regarding the primary key and idempotency_key. Our API has many users and users are only allowed to lookup objects that belong to them. Requests are authenticated so we know the userId…
2
votes
4 answers

Why two primary keys in a table is not allowed?

I want to understand the reasoning behind why two primary keys are not allowed in same table by grammar of MySql. I understand composite key and this is not related to that. I could not understand why two separate primary key in same table is not…
Abhishek Jha
  • 935
  • 2
  • 10
  • 22
2
votes
1 answer

Is UnixNano concatenated with Server ID a good primary key?

I've tried to generate 10k integer from Go's UnixNano, and it doesn't show any collision. package main import ( "fmt" "sync" "time" "strconv" "github.com/OneOfOne/cmap" ) func main() { var wg…
Kokizzu
  • 24,974
  • 37
  • 137
  • 233
2
votes
3 answers

Autonumber vs. Text String for primary key?

I'm trying to find the best solution to an issue I've just come across. I hate doing things without understanding so I'm hoping someone can help. I have an Access database with a table that stores Hotel Information - and then another table that…
arbitel
  • 321
  • 6
  • 22
2
votes
3 answers

Choice of a primary key in SQL table

I want to make an SQL table to keep track of notes that are added/edited/deleted. I want to be able to display the state of each NOTEID at this moment in a table, display log of changes of selected note and be able to delete all notes marked with a…
user6315699
2
votes
3 answers

Is RandomStringUtils.randomAlphanumeric(30) a valid GUID strategy?

I need a random string generator that generates an alpha-numeric string to use as an unique key in a distributed system that is 30 characters or less. It cannot contain any special characters. Will RandomStringUtils#randomAlphanumeric work for…
cosbor11
  • 14,709
  • 10
  • 54
  • 69
2
votes
2 answers

RDBMS primary key design for row versioning

I want to design primary key for my table with row versioning. My table contains 2 main fields : ID and Timestamp, and bunch of other fields. For a unique "ID" , I want to store previous versions of a record. Hence I am creating primary key for the…
sriram
  • 712
  • 8
  • 26