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

Article: "plurality" #21

Open
jemgillam opened this issue Nov 15, 2024 · 0 comments
Open

Article: "plurality" #21

jemgillam opened this issue Nov 15, 2024 · 0 comments

Comments

@jemgillam
Copy link
Collaborator

I really ought to write up an article on "plurality" but that's one of the key things when designing a DB schema: is there always going to be at most one of this? Much easier to go from 2 to 3 than it is to go from 1 to 2. I very often see people add a users.email column; but that's terrible practice - it's very likely a user may have more than one email, they certainly will when they change their email address (a "new" and an "old" one). So "users.email" should actually be a separate table "user_emails" to allow for plurality. The same applies to so many things. Login credentials for example... You might think they "just have a password" but likely there's a lot of ways they might be able to log in in future: OAuth, passkey, etc. Auth credentials should be written plurally. When you break things up like this, not only does it help better plan for the future expansion of your schema, it also gives you more options for optimizing things.

https://discord.com/channels/489127045289476126/1305373087361007666/1305545365982019694

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

1 participant