Which one is best ?

This is a discussion on Which one is best ? within the PHP Language forums, part of the PHP Programming Forums category; Currently I have 3 mysql tables with about 6 columns each, sometimes I have to access to all of them ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-17-2004
Marco
 
Posts: n/a
Default Which one is best ?

Currently I have 3 mysql tables with about 6 columns each, sometimes I have
to access to all of them at the same time but most of the times I access 2
at the same time.

I was wondering which is fast making a single table with about 18 columns,
and each time select the columns that I want in the select query, this way I
would do less select queries.
Or is it better like I have 3 tables, and access 2 of them at the same time
most of the times?

Probably I should post this in a MySQL news server, anyway if someone has
some thoughts about it don't be shy ;)

Thx
Marco


Reply With Quote
  #2 (permalink)  
Old 01-17-2004
Aggro
 
Posts: n/a
Default Re: Which one is best ?

Marco wrote:

> I was wondering which is fast making a single table with about 18 columns,
> and each time select the columns that I want in the select query, this way I
> would do less select queries.
> Or is it better like I have 3 tables, and access 2 of them at the same time
> most of the times?


There is no simple yes or no answer to it, it depends much about what
kind of queries you need to make and how many rows you are supposed to
have in each table.

For example:
If you have 100 000 rows in all tables, and all rows are linked 1 and
only 1 row in other tables, you propably would be better putting all in
one table.

Then again, if you have table with 100 000 rows and another table with
about 10 rows, and each row has a string that you want to do a query
like: select * from nametable where name like '%middletext%';

It would be faster to use different tables. Because if you would have 1
table, you would have to search all rows in it, because you couldn't
benefit from indexes. But when using two tables, you would find the
names by searching 10 rows and then you could use name_id in your larger
talbe, which would be of course indexed.

These are only two examples, but I hope you understant what I'm trying
to say: There is no simple answer to this question.
Reply With Quote
  #3 (permalink)  
Old 01-17-2004
Dasher
 
Posts: n/a
Default Re: Which one is best ?

MySQL is a relational database it is designed to be fast with multiple table
accesses. I have queries that access 5 tables at once. It is still fast.

If you can do the query in a simple wide table... you really don't need a
relational database.



"Marco" <mpgtlatbluewindotch> wrote in message
news:4009341e$1_1@news.bluewin.ch...
> Currently I have 3 mysql tables with about 6 columns each, sometimes I

have
> to access to all of them at the same time but most of the times I access 2
> at the same time.
>
> I was wondering which is fast making a single table with about 18 columns,
> and each time select the columns that I want in the select query, this way

I
> would do less select queries.
> Or is it better like I have 3 tables, and access 2 of them at the same

time
> most of the times?
>
> Probably I should post this in a MySQL news server, anyway if someone has
> some thoughts about it don't be shy ;)
>
> Thx
> Marco
>
>



Reply With Quote
  #4 (permalink)  
Old 01-18-2004
Dan Tripp
 
Posts: n/a
Default Re: Which one is best ?

Marco wrote:
> Currently I have 3 mysql tables with about 6 columns each, sometimes I have
> to access to all of them at the same time but most of the times I access 2
> at the same time.
>
> I was wondering which is fast making a single table with about 18 columns,
> and each time select the columns that I want in the select query, this way I
> would do less select queries.
> Or is it better like I have 3 tables, and access 2 of them at the same time
> most of the times?
>
> Probably I should post this in a MySQL news server, anyway if someone has
> some thoughts about it don't be shy ;)
>
> Thx
> Marco
>
>


I've always leaned toward implementing a more highly normalized (more
granularized) form. The DB developers I've worked with all lean towards
this approach as well.

In the past I've seen how easily I could have "shot myself in the foot"
if I hadn't normalized. Here are some links to articles I thought were
pretty decent:
http://www.serverwatch.com/tutorials...le.php/1549781
http://www.sqlmag.com/Articles/Index...leID=4887&pg=1

http://www.devshed.com/c/a/MySQL/An-...Normalization/

Regards,

- Dan
http://www.dantripp.com/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:13 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0