473,499 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

One Table or Many?

I have a question maybe someone could offer some insight to. I am
currently writing a messaging program that utilizes mysql. I am
debating between the following two situations. Have one table and store
all the messages in there and have a column for user ids. Second, make
a table for each user and store each users' messages in his or her
respective table. I'm thinking the second situation because it would
reduce the file size of one big table. What do you think? Is there a
limit to the size of a table? What about a limit to the amount of
tables one can have in one database? My guess is this program will have
200 users on it, however, I want to have it support many more if needed.
Any input on the matter would be greatly appreciated! Thanks in advance!

Jul 19 '05 #1
1 1980
Grant Nosbush wrote:
Have one table and store all the messages in there and have
a column for user ids. Second, make a table for each user and store each users'
messages in his or her respective table.


Personally, I'd store all the messages in one table, and all
the users in another:

CREATE TABLE Message (
author SMALLINT UNSIGNED NOT NULL, /* foreign key */
when TIMESTAMP NULL, /* when msg was posted */
title VARCHAR(80) NOT NULL, /* title of message */
body TEXT NOT NULL, /* the message itself */
PRIMARY KEY (author, when),
INDEX IMessageWhen (when) /* for ordering by date */
);

/* fixed/static table for faster access */
CREATE TABLE User (
id SMALLINT UNSIGNED NOT NULL PRIMARY KEY,
joined DATETIME NOT NULL, /* when the user joined */
firstName CHAR(15) NOT NULL,
lastName CHAR(20) NOT NULL DEFAULT "Smith"
);

Yes, the Message table will get big. But what kind of
SELECTs do you perceive doing? If all messages are in
separate tables, per user, then you'll have to cancel
out Cartesion joins with a carefully written WHERE clause
that eliminates unwanted permutations to avoid a massive
resultset.

Always think "how will I access the records? What kind of
SELECTs will I use?" That's just my opinion. I'm not a
database expert by any means!

Marco
----------------------------------------------------
Please remove digits from e-mail address (tr/0-9//d)

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
1765
by: Greg | last post by:
Hello, I've to manage many 'table' (having same scheme) on the same server. And I ask myself what could be the best to do (and if you know, why) : Creating as many database (the name would...
2
1398
by: John | last post by:
I'm trying to normalize my database the best I can this time around and I'm running into some trouble. I've been avoid normalizing for a long time now because while I know how to normalize, I'm...
14
4268
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
4
9133
by: Fred | last post by:
Hi. What is the usual and what are the possible fields to use for the primary key of an intersecting table of a many-to-many relationship? I would think the typical, most common fields would...
18
12779
by: Jeremy Weiss | last post by:
I'm trying to build a database that will handle the monthly billing needs of a small company. I'm charting everything out and here's what I see: table for customers sub table to track payments...
5
3727
by: Sami | last post by:
Please bear with me, and if you answer this question, please do it step by step. I am new at Access, not at all sophisticated. I am using Office XP. This will need to be read in Access for...
4
2012
by: sheree | last post by:
I have 3 tables (amoung a few others) in a small access database. The tables are as follows: == AEReport -------- AEID (PK) RptCatelog GCRCID PatientID EvntDate
3
1964
by: CAD Fiend | last post by:
Hello, I have a land development project that has a many-to-many relationship. I have ONE question regarding table structures, and ONE question on how to make a Form with two Subforms, below. ...
117
18408
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of...
76
271440
MMcCarthy
by: MMcCarthy | last post by:
Normalisation is the term used to describe how you break a file down into tables to create a database. There are 3 or 4 major steps involved known as 1NF (First Normal Form), 2NF (Second Normal...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7225
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7392
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5479
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.