Topic: MySql table names (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=28577" title="Pages that link to Topic: MySql table names (Page 1 of 1)" rel="nofollow" >Topic: MySql table names <span class="small">(Page 1 of 1)</span>\

 
redroy
Paranoid (IV) Inmate

From: 1393
Insane since: Dec 2003

posted posted 10-25-2006 22:06

Is it bad practice to name MySql tables starting with numbers? (ie: 1121_table)

DL-44
Lunatic (VI) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 10-26-2006 05:37

I don't know what the official word is, but I would say a big ol' YES!

Preferably a database table will have a name that is meaningful, and preferably one that will also stand out visually.

How often do you want to pull your hair out over your server side code because you transposed a number in your query and don't see it?

Ugh.

(of course, like most things, 'meaning' depends a great deal on context. if such a thing as '1121' has meaning aside from matching an id number, then it may not be as bad as it sounds....but......)

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 10-26-2006 11:23

Really, if you want to start your tables with numbers, chances are high your layout is rather messed up
and worthy of TheDailyWtf.com

redroy
Paranoid (IV) Inmate

From: 1393
Insane since: Dec 2003

posted posted 10-26-2006 14:29

That's what I thought... here's what I'm doing. I've got a controlroom w/ database1 that has all the user info tables and that good stuff... then I've set up another database (database2) that I would like the controlroom to create tables for as I add sites. So if I add another site to the controlroom on database1 like www.web.com it would be givin a unique ID (1121) and then create all the tables needed for it in database2... which will actually hold the content for www.web.com. So, I was thinking it would be easiest to just append the unique ID before the table (1121_faq_table)... I'm I way off here? Thanks for your input.

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 10-26-2006 14:48

You need neither seperate tables nor seperate databases for that.

Just add the site id as a field in your tables for 'sites', add an index for that, and filter on it.
That way would be the right choice nearly all of the time.

The other good way would be to create a database per site - but most hosts don't allow that.


Your proposal isn't normalized, and a bug ugly workaround as well

redroy
Paranoid (IV) Inmate

From: 1393
Insane since: Dec 2003

posted posted 10-26-2006 15:12

Right, that is happening in database1... Sorry, I'm horrible at explaining things.

When I said "hold the content", I meant the actual site content or control content... I've got about 10 different controls that use their own table structures (News, faq, mp3 player, document manager etc.). So, if I add a site (site info, ID, contact info etc. on database1) I can give them different controls (also stored on database1) and those control tables would be set up on database2 by the control. So I can have multiple sites using the same controls with different tables to store the data (1121_faq, 1121_news, 2322_faq).

Right now I have this working with different databases per website... which is a major pain. I'm trying to get things more automated so I can add a website, add controls to it (all within my controlroom) and then just add the line of code to the website to grab the data for that specific control. Hopefully that makes more sense...

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 10-26-2006 15:25

You can create databases in code as well. ( CREATE DATABASE, but your account needs the rights, of course)

But in my opinion, each 'control' should only have one database, and the sites be differentiated by a field within those tables.
You still can have multiple sites, but you have just one table per control type.

redroy
Paranoid (IV) Inmate

From: 1393
Insane since: Dec 2003

posted posted 10-26-2006 18:35

Ah, I see what you're saying... I'll have to go back and re-think the controls then; thanks for your input TP. Peace.



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu