Answer the question
In order to leave comments, you need to log in
How to structure a MySQL database for online writing?
There is a goal to make an online recording, I would like to hear opinions on the structure of the MySQL database for online recording, i.e. how to store data so that it is convenient to process it.
The recording interval can change (10, 20, 30, 40, 50, 60, 90, 120 minutes), every day there can be any interval of working hours (Mon from 8 to 17 (lunch from 12 to 13), Tue from 10 to 16 (without lunch), etc.).
I am lost in thoughts about how to structure everything according to tables and what fields to divide them into. It is necessary to store both general settings for the interval and work schedule, and at the same time individual settings for each day (if the schedule changes on this day or even a weekend). In general, I will be glad to any tips and thoughts on a more or less competent structure of tables.
Answer the question
In order to leave comments, you need to log in
The task is tricky in the sense that it will slip out of your hands at first. Those. you will have to improve the application logic several times until you get the desired result. But don't be afraid to start small. It is very important for the database to know what data you will store and in what form you will receive from it. She will do the rest herself.
Therefore, let's start with the simplest - a table for storing the record itself. Let's name the table `reg` from the word `registration` (Registration). The `id` field is key. `datetime` field - stores the date and time of the entry. The `info` field is arbitrary textual information, no longer than 255 characters.
CREATE TABLE `reg` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'id записи',
`datetime` DATETIME NULL DEFAULT NULL COMMENT 'Дата и время записи',
`info` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'Текстовая информация о записи' COLLATE 'utf8mb4_unicode_ci',
PRIMARY KEY (`id`),
INDEX `datetime` (`datetime`)
)
COMMENT='Регистрация'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question