Skip to content

Explain primary_key and the distinction between primary_key and unique #271

Open
@cloutiertyler

Description

@cloutiertyler

In SpacetimeDB, the only difference between unique and primary_key is that the client SDKs assign special semantics to primary_key columns. Specifically, the on_update callback fires for a row when a single transaction deletes an old row with a certain primary key, and then inserts a new row with that same primary key. Tables without a primary key column will never observe an on_update event. (Also, a table can only have at most one primary key column, but may have as many unique columns as it wants.) Otherwise, the two constraints are equivalent.

Include the above in the docs

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions