Answer the question
In order to leave comments, you need to log in
Are there naming standards primary key, foreign key in the database?
The users table is joined with the city table. Primary key of both tables is named id, foreign key in users is city_id. Maybe there is some kind of naming standard for PK and FK so that there is no name conflict and the need to use aliases (very undesirable)? For example PK - %table%_id, FK - %foreign table%, for my case
users: PK - user_id, FK - city
cities: PK -
city_id in which there will be at most 10 values, or is it better to code (1 - Christian, 2 - Muslim, etc.), and assign a value by code already in the application logic? Starting from how many values does it make sense to start a separate table?
Answer the question
In order to leave comments, you need to log in
No, but if you adhere to a single naming style in the project, everyone will only be happy
stackoverflow.com/questions/199498/foreign-key-nam...
Although oracle has oracle-base.com/articles/misc/naming-conventions.php
Well and just people like to teach how to https://launchbylunch.com/posts/2014/Feb/16/sql-na...
is it worth creating a separate tabledepends on the ORM, the frequency of changing values and the use of the DBMS as a backend for processing (sometimes they distort and write code in the database).
First, the standard is developed within the company or application. Instead of aliases, you can use the table.field format; for example - city.id. This is better than stuffing the table name into an identifier.
The second is to always store everything in the database, do not mix logic and data. What happens if you have the base of one version, and the logic - of another version?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question