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

May be a good idea to use snowflake as the primary key? #12

Closed
dongfengweixiao opened this issue Oct 2, 2022 · 9 comments
Closed

May be a good idea to use snowflake as the primary key? #12

dongfengweixiao opened this issue Oct 2, 2022 · 9 comments

Comments

@dongfengweixiao
Copy link
Contributor

RT

https://github.com/agnirudrasil/avault/blob/c6ca7037a5a99d97fcf43eb6b9ef935439171c02/backend/app/api/utils/snowflake.py

@jonra1993
Copy link
Owner

Hello, @dongfengweixiao what advantage do you expect of using snakeflake vs uuid?

@dongfengweixiao
Copy link
Contributor Author

Hello @jonra1993 , the pros and cons can be read here: https://medium.com/geekculture/the-wild-world-of-unique-identifiers-uuid-ulid-etc-17cfb2a38fce.

Compared with the uuid v1 and the uuid v4, the v4 version has a very low probability of duplication.

@jonra1993
Copy link
Owner

Hello @dongfengweixiao thanks for the link I am going to check it

@bazylhorsey
Copy link
Contributor

If this is done there is no need for the created_at column in any tables it is used, as it would be known by decoding the snowflake

@dongfengweixiao
Copy link
Contributor Author

If this is done there is no need for the created_at column in any tables it is used, as it would be known by decoding the snowflake

Bad idea. All field serves the business logic. The id field should only be used to mark uniqueness. Do not use the id field for additional purposes.

@jonra1993
Copy link
Owner

jonra1993 commented Oct 9, 2022

@bazylhorsey
Copy link
Contributor

@dongfengweixiao may have a point, use your best judgment

@jonra1993
Copy link
Owner

Hello guys, after testing and looking to make the project simple to use and maintain, I have used UUID7 as the database's primary key and added some information about it on the README file including references to alternatives of IDs.

@dongfengweixiao
Copy link
Contributor Author

Hello guys, after testing and looking to make the project simple to use and maintain, I have used UUID7 as the database's primary key and added some information about it on the README file including references to alternatives of IDs.

GREAT!

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

No branches or pull requests

3 participants