1
Hello dear programmers! I’m just a beginner in the world of programming and Stackoverflow and need to ask a question!
I’m making some adjustments in a database I’m working on after finding great guidelines for standardizing fields and tables. As I have two tables that have contact fields (email, phone, optional phone) and address (street, neighborhood, zip code, etc...), I decided to make a table contact and a table addressee which will store this information and have a relationship with the other two tables mentioned.
Since my goal is that this bank be "standardized" so that other programmers find a standardized and easy to understand bank, the ideal is that foreign keys are always at the beginning of the table, after the primary keys, or I can leave the fields in order of importance, regardless of whether they are foreign keys or not?
Oi Hugo, these good practice questions are difficult to answer, each team has its own practices. During the initial design step of the database I try to sort fields in order of importance: Ids, secondary keys, non-zero important fields, other non-zero fields, null fields and finally Fks.
– Anthony Accioly
On the other hand, if the software has already been published I avoid reordering fields. I know it’s the 21st century and no one should have to answer column indexes... but... Anyway, on average during the design phase I try to leave FKS that are not Pks at the bottom of the table. That said, this is a matter of opinion and you can easily find someone who says just the opposite.
– Anthony Accioly
Hi Anthony, thank you for the answer. I will follow your methodology!
– Hugo Guitti