Answer the question
In order to leave comments, you need to log in
How to properly build a MySQL table?
Good time of the day!
I am writing a small service for school (React+PHP+MySQL). I will need to store the schedule for each class. The number of classes is unknown. I want the simplest possible structure.
So far, the simplest brew that came to mind is this:
Answer the question
In order to leave comments, you need to log in
classes (id, number)
subjects (id, name)
teachers (id, full name)
timetable (class_id, subject_id, teacher_id, week_day, lesson_number)
adjustments (class_id, subject_id, teacher_id, date, lesson_number)
Considering three factors:
1. Your statement that the application is planned to be small
2. Such an application will be really small, you are unlikely to make it for school No. 63 in Tyumen, where 26 classes were enrolled this year, even the 1st!))
3 There are really only seven days of the week, there won't be less of them, there won't be more of them, I think it's stupid to start a table for the days of the week, then it's better to create an ENUM type field for this.
All other arguments against - you will not learn how to do joins and queries to several tables in one sitting, you will not care about the possibility of speeding up a query by returning part of the calculations to the php interpreter, etc.
Choose yourself)))
And what kind of sampling is supposed to be done? It can be simplified altogether.
Two fields, class and schedule. Schedule - store in json representation, something like:
{
"понедельник": {
"0": "",
"1": "Алгебра",
"2": "Геометрия"
},
"вторник": {
...
},
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question