Questions tagged [primary-key-design]

77 questions
62
votes
4 answers

MongoDB and composite primary keys

I'm trying to determine the best way to deal with a composite primary key in a mongo db. The main key for interacting with the data in this system is made up of 2 uuids. The combination of uuids is guaranteed to be unique, but neither of the…
herbrandson
  • 2,157
  • 2
  • 30
  • 43
33
votes
2 answers

MySQL - using String as Primary Key

I saw a similar post on Stack Overflow already, but wasn't quite satisfied. Let's say I offer a Web service. http://foo.com/SERVICEID SERVICEID is a unique String ID used to reference the service (base 64, lower/uppercase + numbers), similar to how…
Kenny Cason
  • 11,382
  • 9
  • 42
  • 71
28
votes
1 answer

MySQL - Using foreign key as primary key too

I have table 1 with a primary key user_id and table 2 where user_id is a foreign key. Only 1 record per user_id can exist in table 2, and no record can exist without it. QUESTION: Can user_id in table 2 be both foreign and primary key at the same…
22
votes
1 answer

Is there a DynamoDB max partition size of 10GB for a single partition key value?

I've read lots of DynamoDB docs on designing partition keys and sort keys, but I think I must be missing something fundamental. If you have a bad partition key design, what happens when the data for a SINGLE partition key value exceeds 10GB? The…
Martin Bayly
  • 2,033
  • 2
  • 16
  • 19
15
votes
11 answers

Database Design and the use of non-numeric Primary Keys

I'm currently in the process of designing the database tables for a customer & website management application. My question is in regards to the use of primary keys as functional parts of a table (and not assigning "ID" numbers to every table just…
Nick Jennings
  • 3,518
  • 4
  • 28
  • 40
6
votes
2 answers

Difference between primary key (cluster) and clustered unique index in SQL Server

I understand what is primary key and unique clustered index my question is why primary key is required when we define unique clustered index. Just considering performance good database design. As per my understanding when we define a clustered…
5
votes
3 answers

How can I retrieve the id of a document I added to a Cosmosdb collection?

I have a single collection into which I am inserting documents of different types. I use the type parameter to distinguish between different datatypes in the collection. When I am inserting a document, I have created an Id field for every document,…
5
votes
4 answers

using Natural key as the ID of DomainObject or GUID + auto-increment Domain Driven Design

I've been reading a lot of articles about DDD and noticed that most are using GUID as their ID when persisting to a database. They say that GUID scales well and auto incrementing ID's are a big no-no when it comes to scalability. Im confused now…
5
votes
1 answer

HBase table key design with respect to duplicates and region server hotspotting

I have a requirement to store events generated by a user identified by userId. Each user belongs to a company which is identified by companyId. I have come up with a design for table in HBase as following: rowkey:…
syys
  • 81
  • 2
  • 7
5
votes
2 answers

SSAS One to Many Dimensional Relationship

Question in SSAS for y'all. I am attempting to define a One to Many relationship in an OLAP SSAS cube environment. However, i'm running into problems with defining a primary key. Example tables are below. Relationships between the first 3 tables…
bmcbee
  • 85
  • 2
  • 9
4
votes
2 answers

SQL Primary Keys

So, a co-worker and I are in an argument on which way is better for generating primary keys that are GUIDs. We are using .NET 4.0 with Entities 4 and using stored procs to make select/insert/updates. He wants to create GUID primary key in code and…
Sean
  • 2,205
  • 6
  • 28
  • 53
4
votes
1 answer

How to add prefix to primary key?

I have student table with admission id, i want to add prefix to that admission id when i registered Std Table: S_AdminID S_Name S_Gender 1 eeee M 2 gggg F 14AD is added to asdmission id I want like this S_AdminID …
GuruKumar
  • 61
  • 1
  • 9
4
votes
1 answer

Composite primary key vs single primary key and unique index

I'm modeling a voting system which has the following entities: category nominee phase As the name suggest, I'll be storing categories and nominees in the respective tables. The voting will have two phases. In the first phase there'll be 8 nominees…
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,625
  • 4
  • 26
  • 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,197
  • 17
  • 39
1
2 3 4 5 6