Im trying to decide how Im gonna implement this, I hope that your experience can help me.
The problem
A user login into the webapp using facebook api, this gives me a bunch of data, name, facebook id (Im using that number to identify the user in my site), age, and some other random data that I need to store for later analysis. After that the user can ask for a ticket (just a piece of text with a number generated in a php script), when the ticket is generated I stored the user facebook id, the date (MM/DD/YYYY) and of course a unique id for the ticket, the same user can ask for several tickets.
Solution 1 (the organized one but seems stressful for the mysql server)
To have two tables, one called users
where I store all the user personal information retrived fron the facebook api, including the facebook user id. The second table called Tickets
where to store only the date of the creation of the ticket and the facebook user id of the user who create it, and of course this table have an auto increment unique id to identify the ticket it self.
In the future, I will need to display a list of all the users who created a ticket, displaying not only their facebook user id but also their personal information, so this means I need to query tickets
and for each row/ticket I found using the facebook id I need to query users
to retrive the personal information of that user (name, age, ...). So if I have 10000 tickets created by 10000 uniques users i will need to query my Mysql server 10001, one for retriving an array of tickets and 10000 for retriving the info of each user...
Solution 2 (not that organized as I like)
Intead of having two tables, just have one, where I store everything, tickets and user data, so when a user creates a ticket I store not only the information related with the ticket but also the user personal data in the same table, later if I want to display the list of users who creates a ticket Im just going to make a single query to tickets
that will retrive eventualy (if I have 10000 tickets) a big pack of data that I later will parse using php. These way I have less querys but bigger data.
Right now I have running a basic implentation of the first solution, but now Im a bit worry about scalability issues.
This is how a part of my users
table looks:
And this is tickets
table:
So for listing the users I proceed like this; discount_id
from tickets
represent a type of ticket, so if need the type 1
I query * tickets WHERE discount_id=1, from the array it gives me using the winner_id
(which is the facebook user id of the creator of the ticket) I compre it to the face_id
from users
to retrive the personal information.
I was thinking in a third way to solve this, that is kinda combining 1 and 2, having the same two tables, right after I query tickets
for the type I need, then I query (just one) table users
asking for an array of ALL the user ids tickets
gave me, but I have no idea how to do this and if is worth it.
Which solution is better? Is there a smart way to proceed? Thanks!
ufc on fox 2 weigh ins brandi glanville convulsions john tyler chuck elisabeth hasselbeck fran drescher
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.