General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old November 19th, 2002, 05:47 PM
bitslap bitslap is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: Ottawa, Ontario
Posts: 2 bitslap User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Basic DB Question - Lots of Tables?

Hello,

I'm new at this so please bear with me. I'm creating a MySQL database with a list of users, and associated history events with each user. Suppose there are 300 users, and 100 history events per user.

There are three solutions that I see:

1.
It would seem logical for me to just create a master table for the users, and a table for each user's history events. That means I'm creating 301 tables though. Not only does this fix having to deal with a single table with 30,000 rows, but it also allows faster access since the table is not locked by another user.

2.
I can create the one massive table, with an index for each user's history events.

3.
I blob all of the events into a cell, and then explode them with php.

Which of these solutions is the best, and can you give a little explaination if possible? Thanks a million.

Reply With Quote
  #2  
Old November 19th, 2002, 06:28 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Matt,

If I understand you correctly, you can create 3 tables:

Table: Users
Table: Event History
Table: History Lookup (MV)

The third table, History Lookup, will take care of the multi-values associated with each user; if a user has more than one event in the history, this table to resolve the multi-value issues of a Many-to-Many relationship.

What you would store in the table is the User ID and the associated Event ID.

If you need help, let me know.

Btw: Hello to a fellow Canadian! Where abouts are you from?
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #3  
Old November 19th, 2002, 07:16 PM
bitslap bitslap is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: Ottawa, Ontario
Posts: 2 bitslap User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hey hey. I'm in Ottawa

It's a one-to-many relationship I believe...

If I were to use a table for lookups, I envision something like this...

TABLE users:
userid
password
email
eventid1
eventid2
eventid3
etc.

TABLE historyevents:
id
event_description
date

This means I need over 100 columns for the first table?

Thanks for your help.

Reply With Quote
  #4  
Old November 22nd, 2002, 05:47 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Okay, I didn't understand correctly! I thought the events were pre-created values... But I see what you mean now.

Still, you're better of creating your tables like so:

TABLE users:
userid
password
email

TABLE historyevents:
eventid
event_description
date

TABLE user-events:
userid
eventid

You don't want to have your users table with columns: event1, event2, event3, etc... because not all users will have the same number of events, and you don't know what the maximum number of events will be. By using 3 tables, you can have a variable number of events for each user.

Hope that helps... Let me know.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > Basic DB Question - Lots of Tables?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway