store array in one filed sql

Hello

I have table “employee” and has fields "id, first_name, last_name, day1 day2, day3, day4, day5, day6, day7)

I want to store arrary on days field

like time start work and time stoped and some employees work more than one shift, so I want to store start1, end1, start2, end2,

who i can do that

You shouldn’t store the worked hours in the same table as the employee info. Only put the id, first_name and last_name in the employee table. Then make another table that has:

id - autoincrement
employee_id - use int format - this will be like a foreign key to the employee table so it relates directly back to a id in the employee table.
date_worked - use date format
start1 - use datetime format
end1 - use datetime format
start2 - use datetime format
end2 - use datetime format

Then you would only enter data to the new table for the hours worked and insert the employees id in the employee_id column.

What fastsol is referring to is called “Database Normalization”. It is important and you should understand and know about it. Google is your friend.

Sponsor our Newsletter | Privacy Policy | Terms of Service