![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
The book "SQL Queries for Mere Mortals" says to prepend the table name to all of your columns. Other books might say prepend the table name to the primary key column, e.g., student_id and then also use this name as the foreign key. Yet other books would say simply call the primary key id and call the foreign key student_id. Does anyone have any feedback on the "best" way to do this? Which books would you recommend for reference on this topic? |
#3
| |||
| |||
|
|
I've seen all schemes above in real life and my only recommendation is to find a naming scheme that you like and stick to it. The worst situation is when people start mixing different naming schemes. |
#4
| |||
| |||
|
|
Yet other books would say simply call the primary key id and call the foreign key student_id. |
|
Does anyone have any feedback on the "best" way to do this? Which books would you recommend for reference on this topic? |
#5
| |||
| |||
|
|
My approach can be found here http://www.gplivna.eu/papers/naming_conventions.htm |
|
Warning - I'v never said that it is the best one and I'v discussed with people thinking this scheme is horrible. Usually this is just a matter of taste and habit. |
#6
| |||
| |||
|
|
Gints Plivna wrote: My approach can be found here http://www.gplivna.eu/papers/naming_conventions.htm The one rule of yours I disagree with is this one: quote>Table names are in plural form, for example, persons, materials, addresses. </quote The concept wasn't mine. It is introduced at least in Barker, R. 1990. |
#7
| ||||
| ||||
|
|
The one rule of yours I disagree with is this one:<quote>Table names are in plural form, for example, persons, materials, addresses. </quote |
|
To my mind, a table of people is a table in which each row is a person. |
|
The table should be named for the rows it has in it. |
|
Just like in C programming an array is a container in which each element is a single thing. |
#8
| |||
| |||
|
|
The book "SQL Queries for Mere Mortals" says to prepend the table name to all of your columns. Other books might say prepend the table name to the primary key column, e.g., student_id and then also use this name as the foreign key. Yet other books would say simply call the primary key id and call the foreign key student_id. Does anyone have any feedback on the "best" way to do this? Which books would you recommend for reference on this topic? Finally, in a good database, one would use REFERENCES to explicitly state foreign keys but some databases have to use naming conventions to provide hints to tools which reverse engineer schemas into diagrams. I wonder which convention they use. Thanks for any input. |
#9
| |||
| |||
|
|
We used a system like this on the mainframe for copybooks. The problem with our COBOL is you have to use Global Variables and none can ever be duplicated. Not true! COBOL has an excellent system for qualifying names and |
![]() |
| Thread Tools | |
| Display Modes | |
| |