首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >健身课预约系统的数据库模式

健身课预约系统的数据库模式
EN

Stack Overflow用户
提问于 2010-10-13 03:41:59
回答 2查看 1.3K关注 0票数 1

我需要一个健身课程的模式。

预订系统需要存储它可以接受的最大学生数量,预订加入班级的学生数量,学生ids,日期时间等。

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

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

提前谢谢。

EN

回答 2

Stack Overflow用户

发布于 2010-10-13 03:45:16

代码语言:javascript
复制
Student: ID, Name, ...
Class: ID, Name, MaxStudents, ...
Student_in_Class: STUDENT_ID, CLASS_ID, DATE_ENROLL
票数 1
EN

Stack Overflow用户

发布于 2010-10-14 07:13:44

*不是mySql专家,我通常是和mySql打交道的,但我想你会明白的。您可能需要在mySql文档中进行一些挖掘,以找到与我建议的数据类型相匹配的适当数据类型。此外,我只给出了一些类型的简要说明,以阐明它们的用途,因为这是mySql而不是mySql。

Class_Enrollment -存储每个学生注册的类

代码语言:javascript
复制
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 -存储您的类

代码语言:javascript
复制
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")

学生-存储你的学生

代码语言:javascript
复制
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,除非它是一个非常大的数据库。否则,请考虑使用名字、姓氏和电话作为唯一约束)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3918373

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档