开发者

Creating a suitable database setup for a scheduler

开发者 https://www.devze.com 2023-03-12 09:42 出处:网络
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.

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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消