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

发布于 2024-09-27 07:53:23 字数 162 浏览 2 评论 0原文

我需要一个健身课的方案。

预订系统需要存储它可以容纳的最大学生人数、预订加入班级的学生人数、学生 ID、日期时间等。

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

我希望能得到一些好主意。

提前致谢。

I need a schema for fitness class.

The booking system needs to store max-number of students it can take, number of students who booked to join the class, students ids, datetime etc.

A student table needs to store classes which he/she booked. But this may not need if I store students ids in class tables.

I am hoping to get some good ideas.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦里泪两行 2024-10-04 07:53:23
Student: ID, Name, ...
Class: ID, Name, MaxStudents, ...
Student_in_Class: STUDENT_ID, CLASS_ID, DATE_ENROLL
Student: ID, Name, ...
Class: ID, Name, MaxStudents, ...
Student_in_Class: STUDENT_ID, CLASS_ID, DATE_ENROLL
回眸一遍 2024-10-04 07:53:23

*不是 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 - 存储您的班级

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 - 存储您的学生

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 和出生日期上放置唯一约束索引以消除重复(您可能有两个约翰·史密斯,但在同一个数据库中不太可能出现两个具有完全相同出生日期的约翰·史密斯,除非它是一个非常大的数据库,否则,请考虑使用名字、姓氏和电话作为唯一约束)。

*Not a mySql guru, I typically deal w/ MS SQL, but I think you'll get the idea. You might need to dig a little in the mySql docs to find appropriate data types that match the ones I've suggested. Also, I only gave brief explanation for some types to clarify what they're for, since this is mySql and not MS SQL.

Class_Enrollment - stores the classes each student is registered for

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")
  • put a unique constraint index on class_id and student_id to prevent duplicates

Class - stores your classes

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 - stores your students

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")
  • put a unique constraint index on fname, lname, and date of birth to eliminate duplicates (you may have two John Smiths, but two John Smiths w/ exact same birth date in same database is unlikely unless it's a very large database. Otherwise, consider using first name, last name, and phone as a unique constraint)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文