E
E
enchikiben2011-12-26 08:22:28
Database design
enchikiben, 2011-12-26 08:22:28

Database design

Good morning!

Prompt as it is better to design the table storing time of work of the company? With maximum functionality ... I

thought to make 6 columns

id
id_company
day - day of the week
time_start - start time
time_stop - end time
type - type (lunch or not)

sort by time when selecting and it seems that something should work out

Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Zheltyakov, 2011-12-26
@EnChikiben

id
id_company
time_start - start time
time_stop - end time
time_start_dinner - start time of lunch (break)
time_stop_dinner - end time of lunch
time_last - end time of the shortened day.
type - day type field.
The types are as follows:
- Weekend,
- Weekday with a break,
- Weekday without a break,
- Monday,
- ...
- Sunday.
— Shortened day
Something like this. For all occasions.

G
gennad, 2011-12-26
@gennad

====intervals====
id
company_id: INT
start: DATETIME
end: DATETIME
type_id: Foreign key to events
====events====
id: PK
type_name: CHAR
is_work_time: BOOLEAN
… The
query would be something like this:
SELECT TIMEDIFF(end, start) as diff FROM intervals SORT BY diff;

R
rPman, 2011-12-26
@rPman

What are you going to do with this data?
You need at least 2 lists - 'working days' + 'weekends' (or rather 'non-working' and mark lunch in this way), the time format is more convenient according to the crontab type (by field per time level), then queries like - which company works on another company's lunch time will be relatively simple.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question