2uzhan.com
Advertisement
Now Place:2uzhan.com » Basic DB Question - Lots of Tables?

Basic DB Question - Lots of Tables?

PHP @ December 30, 1969   Views:0

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 explanation if possible? Thanks a million.

--------------Solutions-------------

Hi,

Two tables: One for unique users, one for unique events should work:

Table users:
Id (User identifier number, unique)
Name
email
etc

Table events:
Id (Event identifier)
UserNr (refers to users.Id, here not unique)
Date
etc.

Query:

Select * from events, users where users.Id = $ID

J.

Tags:
© 2018 2uzhan.com Contact