Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain primary_key and the distinction between primary_key and unique #271

Open
cloutiertyler opened this issue Mar 16, 2025 · 0 comments · May be fixed by #274
Open

Explain primary_key and the distinction between primary_key and unique #271

cloutiertyler opened this issue Mar 16, 2025 · 0 comments · May be fixed by #274
Assignees

Comments

@cloutiertyler
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants