Skip to content

Commit

Permalink
docs: clarify primary key uniqueness requirement. (#503)
Browse files Browse the repository at this point in the history
Not globally unique across tables.
  • Loading branch information
thruflo authored Sep 28, 2023
1 parent 5a0f922 commit d53408c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/reference/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ By understanding and acknowledging these constraints, you can leverage ElectricS

### Uniqueness constraints

#### Primary keys need to be globally unique
#### Primary keys need to be unique

In centralised databases, the creation of two rows with the same primary key causes one of the transactions to abort. In local-first applications, that conflict would only be detected after-the-fact, leaving the state of clients unreconcilable. In ElectricSQL, we require that each key can only be created by a single client at any point in time, ensuring that primary keys are globally unique.
In centralised databases, the creation of two rows with the same primary key causes one of the transactions to abort. In local-first applications, that conflict would only be detected after-the-fact, leaving the state of clients unreconcilable. In ElectricSQL, we require that each key can only be created by a single client at any point in time, ensuring that primary keys are unique (to their table -- rows in different tables can have the same primary key value).

To ensure that primary keys are globally unique, you can use:
To ensure that primary keys are unique, you can use:

- UUIDs are typically a safe approach (be aware of limitation with some browsers and devices [REF])
- Unique data about the client for generating the value safely. E.g., use the clientId in a composed primary-key.
Expand Down

0 comments on commit d53408c

Please sign in to comment.