简体   繁体   English

如何管理 MySQL 数据库表中用户的可用性

[英]How to manage availability of a user in MySQL database tables

I am trying to make a database design and I have a tutor which can set his availability in two ways :我正在尝试进行数据库设计,并且我有一位导师可以通过两种方式设置他的可用性:

  1. General availability in a week.一周内全面上市。 Which basically tells that usually I'm free to teach on these days of week between these hours of those days.这基本上表明,通常我可以在这些天的这些时间之间的这些天自由教学。 Eg I'm available on Monday from 4PM to 8PM, on Tuesday on 10AM to 1PM, etc.例如,我周一下午 4 点到晚上 8 点有空,周二上午 10 点到下午 1 点有空,等等。
  2. Specific availability.特定的可用性。 Which tells that on this date I won't be available on general availability time but instead on these hours.这表明在这个日期我将无法在一般可用性时间使用,而是在这些时间使用。 Eg I'm available on Monday 28 June from 2PM to 5PM.例如,我在 6 月 28 日星期一下午 2 点到下午 5 点有空。 If specific availability for a date is present then general availability won't be shown.如果存在某个日期的特定可用性,则不会显示一般可用性。

How do I design tables in order to save this availability information ?我如何设计表格以保存此可用性信息?

For example provided your DB supports Time type, pseudocode例如,如果您的数据库支持Time类型,伪代码

GeneralAvailability (
    TutorId int not null,
    DayOfWeek int not null, /* 1 .. 7*/
    TimeFrom Time not null,
    TimeTo Time  not null
) 

SpecialAvailability (
    TutorId  int not null,
    AvailDate Date not null, 
    TimeFrom Time not null,
    TimeTo Time  not null
) 

or generalized one或广义的

Availability (
    TutorId int  not null,
    DayOfWeek int, /* 1 .. 7, null */ 
    AvailDate Date, 
    TimeFrom Time  not null,
    TimeTo Time  not null,
    CHECK ((DayOfWeek IS NULL OR AvailDate IS NULL) AND (DayOfWeek IS NOT NULL OR AvailDate IS NOT NULL))
) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM