The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 07, 2010, 12:39:03 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Seperate Tables or Databases?  (Read 269 times)
Keebler
Rookie
**
Offline Offline

Posts: 18


View Profile
« on: September 30, 2009, 09:18:16 PM »

Is it common to make new tables for like every group that joins a cms you have?

Like...

group id = 15

table name = 15group

and multiple tables like that?

15content
15history

etc?

or what is the most common practice to organize and store information
Logged
isthisthingon
Global Moderator
Lifer
*****
Online Online

Posts: 2473


Cooperation > Competition


View Profile
« Reply #1 on: September 30, 2009, 09:35:48 PM »

 D'oh!  Nope.  I'd take some time to absorb the great bedtime reading of the first normal form: http://en.wikipedia.org/wiki/First_normal_form

Lot's of normalization theorists are just that - theorists.  However, the principles of normalization balanced against the realities of de-normalization should be in the toolbox of every engineer.  Normalization saves space by eliminating data duplication.  However, taken to it's extreme, normalization can make a database unusable, slow and unnecessarily complicated to program against. 

Initial thought to your question.  Consider:

Group
-----
Id
Name (15)
Region
Anything occurring only once

GroupDetails
------------
Id
GroupId (parent Id, pointing to Group)
Detail (the "many" in this one-to-many relationship)

Then something like:

SELECT Detail FROM GroupDetails WHERE GroupId = :groupIdVar;

So you wind up with any number of master group record entries instead of new tables and each master Id has any number of detail children that belong only to them, in only two tables.

Just cranked this out in a hurry - moving.  No time to proof it Smiley

Good luck...
Logged

"There is a coordinated effort to devalue everything you value." - Glenn Beck
"You see, a pimp's love is very different from that of a square." - Officer Collins, Idiocracy
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 8758



View Profile
« Reply #2 on: September 30, 2009, 10:38:06 PM »

Is it common to make new tables for like every group that joins a cms you have?

Like...

group id = 15

table name = 15group

and multiple tables like that?

15content
15history

etc?

 Shocked

That's downright scary. Have you done much reading up on relational databases? Consider purchasing something like, "Learn SQL in 24 hours" (SAMS) - I actually did read that one and the exercises are fine. You'll get an idea for how things work right quick.

ITTO is right, you should also become familiar with (at the VERY least) the first of the 5 normal forms: http://en.wikipedia.org/wiki/First_normal_form

Here's an about.com that's quick and easy: http://databases.about.com/od/specificproducts/a/normalization.htm

Logged

It's the things you learn after you know it all that really count.
-John Wooden
lamontagne
Rookie
**
Offline Offline

Posts: 48


View Profile
« Reply #3 on: September 30, 2009, 10:58:16 PM »

yes it is common... in fact it's retarded.. you should create a new file for everything... flatfiles for life!
Logged

"Long time no see. I only pray the caliber of your questions has improved." - Kevin Smith
isthisthingon
Global Moderator
Lifer
*****
Online Online

Posts: 2473


Cooperation > Competition


View Profile
« Reply #4 on: September 30, 2009, 11:30:32 PM »

Quote
you should create a new file for everything

But single-file source code is always the best policy Wink
Logged

"There is a coordinated effort to devalue everything you value." - Glenn Beck
"You see, a pimp's love is very different from that of a square." - Officer Collins, Idiocracy
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Online Online

Posts: 1605



View Profile
« Reply #5 on: October 01, 2009, 08:25:35 AM »

I got into a kick where I would ridiculously normalize my databases for a while. MySQL just could not handle it. Never really got me into trouble when I was running on appropos hardware, but it would just kill my shared hosting in seconds flat.
Logged

nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5329


DAMN YOU!!!!!!!


View Profile
« Reply #6 on: October 01, 2009, 03:46:09 PM »

i can always tell when I pick up a project from a prior dev, who it seems just got over their head.
Either the tables are massive, meaning they never done this before at all.
or the tables are so over-normalized that just to get any pieces of data you have to do 8way joins, and in the end, just end up creating Guy#1's table as a temp in ram.

The ones that concern me are the "this guy obviously knows what he's doing, but holy shit, WTF is this for?"
(I have generated a few of those... 1 client in particular.) Inheritance is a bitch.
Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!