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

Database - primary keys should be id #92

Open
urbantumbleweed opened this issue Jan 9, 2016 · 0 comments
Open

Database - primary keys should be id #92

urbantumbleweed opened this issue Jan 9, 2016 · 0 comments

Comments

@urbantumbleweed
Copy link
Contributor

Currently the schema names of a given table as follows

salespersons -> salesperson_id
salesperson.salesperson_id
clients -> client_id
client.client_id

When the id represents the table in which it is a record, then the id should be simply id. On the other hand if the id is a foreign key on a record on another table it should have the format <record-type>_id.

For example:
when referencing clients on a sales record then we can use salesperson.client_id. This makes it easier to determine which is the primary table in queries when creating joins. We might have a where clause that looks like:

salesperson.id = client.salesperson_id
or
client.id = salesperson.client_id

It is clear which is table the id is the primary property

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

No branches or pull requests

1 participant