I am not aware of any document that describes naming conventions, but through my use of databases and design I have found a scheme that works for me. I follow these rules:
1. The autoincrement field (or unique id) for a table is named "tablename" ++ "id". So if the table is "books" the unique identifier for the row would be "bookid". 2. When an attribute in one table is the same as in another table (ie in the table "books" I might want to reference a row in the "author" table in which case I would name the attribute in the books table "authorid"). 3. I use lowercase names for both tables and attributes.. The reason is I am not a big fan of uppcase letters unless they serve a purpose (like in OO the class name would be upper case while methods on the class are lowercase). In SQL there isnt much of a need to diferentiate between a table and a attribute because you can determine easily what the name is from the context in which it was used in the query. But I think this is a preference thing, I could see someone thinking its very useful. 4. When naming an attribute I try to reflect the meaning of the data as much as possible in the attribute name. Because SQL doesnt let you easily convey to the client what the field means, you must do it in the attribute name. So instead of using something like "aptno" for a field I would choose "apartmentnumber". 5. If you use "apartmentnumber" in one table, make sure to call other references to it "apartmentnumber" as well... Dont change it to "aptno". This follows from rule 2, I just thought I would say it again in another way. :P The same goes for code that uses these attributes. If a variable holds the value from the "apartmentnumber" attribute, dont call it "aptno". It might be clear in this example where that data came from but that may not hold for other examples... and definitly if someone is going over your code who is not familiar with the database it will help (or if you havent looked at the code in a really long time). That is about it for now... anyone care to add? ryan > I've been developing in MySQL for some time now, but as I go along I've > noticed that my naming conventions have changed dramatically, and I was > wondering if there is like a set of guidelines or something I could take > a look at. A set of standards, if you will, for naming conventions of > fields in tables in MySQL databases. > > For example, using all lowercase for field names, separating words with > underscores, or not, and whether to use a descriptive auto_increment id > (such as userid, newsid) or if to just use "id" for every table. > > Any discussion on this is much appreciated. > > Mike --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php