【问题标题】:DB schema for a booking system of fitness class健身课程预订系统的数据库模式
【发布时间】:2010-10-15 02:38:14
【问题描述】:

我需要健身课程的架构。

预订系统需要存储最多可容纳的学生人数、预订加入课程的学生人数、学生 ID、日期时间等。

学生表需要存储他/她预订的课程。但如果我将学生 ID 存储在班级表中,这可能不需要。

我希望能得到一些好的想法。

提前致谢。

【问题讨论】:

    标签: mysql database-design schema


    【解决方案1】:
    Student: ID, Name, ...
    Class: ID, Name, MaxStudents, ...
    Student_in_Class: STUDENT_ID, CLASS_ID, DATE_ENROLL
    

    【讨论】:

      【解决方案2】:

      *不是 mySql 大师,我通常处理 MS SQL,但我想你会明白的。您可能需要在 mySql 文档中进行一些挖掘,以找到与我建议的数据类型相匹配的适当数据类型。另外,我只对某些类型进行了简要说明以阐明它们的用途,因为这是 mySql 而不是 MS SQL。

      Class_Enrollment - 存储每个学生注册的课程

      Class_Enrollment_ID INT IDENTITY PK ("identity is made specifically
          to serve as an id and it's a field that the system will manage 
          on its own.  It automatically gets updated when a new record is
          created.  I would try to find something similar in mySql")
      Class_ID INT FK
      Student_ID INT FK
      Date_Time smalldatetime ("smalldatetime just stores the date as a
          smaller range of years than datetime + time up to minutes")
      
      • 在 class_id 和 student_id 上设置唯一约束索引以防止重复

      类 - 存储你的类

      Class_ID INT IDENTITY PK
      Name VARCHAR('size') UNIQUE CONSTRAINT INDEX ("UNIQUE CONSTRAINT INDEX is
          like a PK, but you can have more than one in a table")
      Max_Enrollment INT ("unless you have a different max for different sessions
          of the same class, then you only need to define max enrollment once per
          class, so it belongs in the class table, not the Class_Enrollment table")
      

      学生 - 存储您的学生

      Student_ID INT IDENTITY PK
      First_Name VARCHAR('size')
      Last_Name VARCHAR('size')
      Date_of_Birth smalldatetime ("smalldatetime can store just the date,
          will automatically put 0's for the time, works fine")
      
      • 在 fname、lname 和出生日期上放置唯一约束索引以消除重复项(您可能有两个 John Smith,但在同一个数据库中不太可能有两个出生日期完全相同的 John Smith,除非它是一个非常大的数据库。否则,请考虑使用名字、姓氏和电话作为唯一约束)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-01-28
        • 1970-01-01
        • 2012-03-06
        • 2021-05-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多