473,396 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1978
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
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
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
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
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
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
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
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
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
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
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
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,...

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.