NYCPHP Meetup

NYPHP.org

[nycphp-talk] Database, table, and column naming schemes

David Krings ramons at gmx.net
Tue Oct 6 07:10:00 EDT 2009


Matt Juszczak wrote:
> And how about one more thing...
> 
> What would you call a table that joins two other tables on a many to many:
> 
[...]
> 
> What would you call that many:many table?
> 
> Surely, not account_user, and not user_account, as that's deceiving. 
> Would you do something like:
> 
> x_account_user
> 
[...]

> Thoughts?

So you have a need to craft a new table that consists of columns found in 
other tables? I recommend using a view instead rather than to duplicate the 
data and needlessly bloat the database. Views behave like tables (except that 
you cannot insert or update data through them), so you can run queries against 
them and as far as I know create new views from existing views and tables. I 
recently started playing around with views at my job and was positively 
impressed about how easy they are to create and how much work they save. There 
really is no need to store the same piece of data more than once in a 
database. Works well for tables that are commonly joined or pieces of data 
that need to be calculated, filtered, sorted, or whatever SQL allows you to do.
In regards to naming, looking at other databases the views are prefixed with 
"v_" or some use "vw_". So in your case the name could be "v_account_user".

Might that work for you?

David




More information about the talk mailing list