That seems to follow how I've been doing it as well. For example, consider this database set up:
Table: news Fields: newsid int(10) userid int(10) dateposted datetime subject varchar(255) content text Table: users Fields: userid int(10) name varchar(60) and on and on. I'd love to hear from some hard-core developers. Guys who have been doing database development professionally for years. Mike ryc wrote: >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 > --------------------------------------------------------------------- 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