[thelist] Database Naming Conventions
VOLKAN ÖZÇELİK
volkan.ozcelik at gmail.com
Wed Mar 15 14:18:24 CST 2006
Here is a typical user table that exemplifies some of the naming conventions
I use:
CREATE TABLE `tbluser` *(
*`lngUserID` int*(*11*) *NOT NULL auto_increment*,
*`intUserType` tinyint*(*4*) *NOT NULL default '0'*,
*`intStatus` tinyint*(*4*) *NOT NULL default '0'*,
*`intRank` int*(*11*) *NOT NULL default '0'*,
*`intCountryCode` tinyint*(*4*) *NOT NULL default '0'*,
*`strUserName` varchar*(*20*) *NOT NULL default ''*,
*`strPassword` varchar*(*8*) *NOT NULL default ''*,
*`strEmail` varchar*(*250*) *NOT NULL default ''*,
*PRIMARY KEY *(*`lngUserID`*),
*UNIQUE KEY `IX_unq_strUserName` *(*`strUserName`*),
*UNIQUE KEY `IX_unq_strEmail` *(*`strEmail`*)
) *TYPE*=*MyISAM COMMENT*=*'table of users'*;
*
Details:
tbl -> tables
qry -> views
tlkp -> lookup tables
sp -> stored proecures
prefixes:
lng -> long
dbl -> double
int -> numeric
str -> varchar,char etc
txt -> text
ID convention: lngTableNameID
I find these conventions helpful especially when iterating through the
database schema.
Although using hungarian notation (the int, str, tbl, qry etc stuff) as per
naming conventions is debatable,
since even M$ dropped using that notation because, they say, it was
overcomplicating things.
Anyway I think it adds a bit more organization.
However, imho, It is better to stick to a convention and continue using it
rather than going back and forth between several conventions, especially at
early development phase of a project.
HTH,
--
Volkan Ozcelik
+>Yep! I'm blogging! : http://www.volkanozcelik.com/volkanozcelik/blog/
+> My projects/studies/trials/errors : http://www.sarmal.com/
More information about the thelist
mailing list