php - update database entry and/or preserve exisisting entries -


i building php application checks birthdays of users in database. these users granted variety of gifts @ birthday, may pick one. keep track of picked, can see has claimed gift , still has gift waiting.

the target group of application companies, pay fee per employee part of application. application made make easier companies remember employees birthdays , show care.

as companies grow/shrink, hiring, firing employees, update employee list every month system able exclude no longer work there , add new employees.

now question is: how do smartest way?

if remove every employee associated given company, when given current employee roster, , insert new list scratch, loose association between employee , un/claimed gift in database.

on other hand, make sure preserve association in database, if add new employees , remove no longer on roster, how go smartest way?

the fields got on employees id, firstname, surname, email, birthday , company_id. neither of these way identify whether user in database (can argue email might work, if reason changed it, wouldn't work)

any suggestions more welcome.

the simplest answer add employee_id database. every company has internal ids use identify employees internally within system. necessary many purposes, including payroll, benefits, attendance, etc. therefore need add id field employee table , ensure roster receive contains these ids employees.

in addition, rather deleting entries employees no longer work company, can have flag indicating whether employment still active. add corresponding where clause queries.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -