A
A
ADA M2017-09-30 01:56:31
MySQL
ADA M, 2017-09-30 01:56:31

Designing an e-journal database?

For the purpose of self-development, I set myself the task of creating an application, which is an electronic journal of the school.
I implemented most of the idea on Yii2, then I ran into the problem of updating the ratings in the database.
There is the following database structure:
59cecbcc6fcd5012662171.pngfig. 1
Accordingly, the current_score table (current score) will be filled in as follows (from 1/09 to 31/05):
59cecc68b7649316325517.pngfig. 2
My task was to create a journal that can be filled in by the teacher in the context of subjects and students. That. the form for entering grades will be as follows:
59ceccd34137e389376823.pngfig. 3
And at this point I stopped. It turns out that when sending a POST request to update the form, 3 operations with the database (current_score table) will be performed: CREATE, UPDATE, DELETE.In other words, if new grades were entered, corresponding records are created; if grades were deleted from the cells of the form, the record data is deleted, and the usual update.
In order not to handle 3 operations, I considered various options such as:

  1. When making a POST request, the first step is to delete all data by student/subject id and then write the data from the request (2 operations are obtained). In this case, if you fail to write data, you can lose all previous rating data, I think.
  2. Pre-create "blank" records without grades in the table for each date from 1/09 to 31/05 (school year, 270 days somewhere). But there is a problem with the optimal use of the database, I think there should not be empty cells with estimates.

I was looking on the Internet for something similar, where data entry is carried out in a tabular form and may have a variable number of columns (dates). Didn't find anything like it.
Please tell me how you would implement data entry into the log (Fig. 3).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TheLostRoot, 2017-09-30
@adiletmurzaliev

No need to be smart here, do 3 operations and that's it. Don't focus on the number of transactions. Look at the cost of doing them.
Imagine how many grades a student will have in a year and delete them all with each editing? What if many users start editing at the same time? Wait until everyone deletes all their marks, and then writes them down again? IMHO stupid approach.

D
DTX, 2017-09-30
@DirecTwiX

Rewriting the entire magazine - that's another idea. Send three arrays from the client - added, changed, deleted ratings.
And it doesn’t hurt to learn how to mark the correct answers as a solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question