Creating a suitable database setup for a scheduler
I am creating a scheduler web app that stores its data in a mysql database, and right now I'm trying to figure out the best way to set up the tables in it.
It will support multiple users, and I want it to be able to handle a large user base (let's say many thousands).
Each user will have some usual data associated with them (username, password, preferences) and also their events.
Each user can have anywhere from 0 to 1000s of events, with each event having information such as start time, end time, name, etc.
So there will be many of these: User
- username
- passw开发者_JAVA百科ord
- preferences
- events
- name
- start time
- end time
another thing is, i'd like each individual event to be queryable. I'd like to be able to modify event # of ___ user.
How can I set this up so it's not super complicated or really slow?
user table
user_id, username, password, preferences
Make user_id as the primary key.
event table
event_id, user_id, name, start_time, end_time
Make {event_id, user_id} a primary key.
This should do? If you are expecting thousands of events where many events can be duplicates but related to different users, you may create an event table without user_id and then create a new table to hold {event_id,user_id} combination.
PS: don't store the password in plain text; consider moving preferences to separate table.
精彩评论