Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Есть такая бд:
- employee:
- +----+----------------+-------------------+-------------+
- | id | name | email | skype_id |
- +----+----------------+-------------------+-------------+
- | 1 | Ivan Petrov | petrov@mail.ru | ivan_petrov |
- | 2 | Dmitry Voronov | dmitry@mail.ru | dm_dm |
- | 3 | Elena Smirnova | smirnova@area9.dk | smir-el |
- +----+----------------+-------------------+-------------+
- project:
- +----+---------+-------------+
- | id | name | description |
- +----+---------+-------------+
- | 1 | Drive | d |
- | 2 | Essence | e |
- | 3 | AdWords | a |
- +----+---------+-------------+
- allocation:
- +----+------+----------+---------+------------------+
- | id | week | employee | project | work_description |
- +----+------+----------+---------+------------------+
- | * | * | * | * | * |
- +----+------+----------+---------+------------------+
- Вот так сейчас работает обычный дропдаун:
- === CASE 1 ===
- // меняем выбранный элемент дропдауна в репорте
- +----------------+--------+ +----------------+---------+
- | | week 1 | | | week 1 |
- +----------------+--------+ ===> +----------------+---------+
- | Elena Smirnova | Pick | | Elena Smirnova | AdWords |
- +----------------+--------+ +----------------+---------+
- // изменения в бд
- Add record:
- +----+------+----------+---------+------------------+
- | id | week | employee | project | work_description |
- +----+------+----------+---------+------------------+
- | 1 | 1 | 3 | 3 | NULL |
- +----+------+----------+---------+------------------+
- === CASE 2 ===
- +-------------+--------+ +-------------+---------+
- | | week 1 | | | week 1 |
- +-------------+--------+ ===> +-------------+---------+
- | Ivan Petrov | Drive | | Ivan Petrov | AdWords |
- +-------------+--------+ +-------------+---------+
- Update record (work_description остается прежним):
- +----+------+----------+---------+------------------+ +----+------+----------+---------+------------------+
- | id | week | employee | project | work_description | | id | week | employee | project | work_description |
- +----+------+----------+---------+------------------+ ===> +----+------+----------+---------+------------------+
- | 1 | 1 | 1 | 1 | d1 | | 1 | 1 | 1 | 3 | d1 |
- +----+------+----------+---------+------------------+ +----+------+----------+---------+------------------+
- Так будет если добавить мультиселект дропдаун:
- === CASE 1 ===
- +----------------+--------+ +----------------+----------------+
- | | week 1 | | | week 1 |
- +----------------+--------+ ===> +----------------+----------------+
- | Elena Smirnova | Pick | | Elena Smirnova | Drive, AdWords |
- +----------------+--------+ +----------------+----------------+
- Add record:
- +----+------+----------+---------+------------------+
- | id | week | employee | project | work_description |
- +----+------+----------+---------+------------------+
- | 1 | 1 | 3 | 1 | NULL |
- | 2 | 1 | 3 | 3 | NULL |
- +----+------+----------+---------+------------------+
- === CASE 2 ===
- +-------------+--------+ +-------------+---------+
- | | week 1 | | | week 1 |
- +-------------+--------+ ===> +-------------+---------+
- | Ivan Petrov | Drive | | Ivan Petrov | AdWords |
- +-------------+--------+ +-------------+---------+
- Delete record:
- +----+------+----------+---------+------------------+
- | id | week | employee | project | work_description |
- +----+------+----------+---------+------------------+
- | 1 | 1 | 1 | 1 | d1 |
- +----+------+----------+---------+------------------+
- Add record:
- +----+------+----------+---------+------------------+
- | id | week | employee | project | work_description |
- +----+------+----------+---------+------------------+
- | 2 | 1 | 1 | 3 | NULL |
- +----+------+----------+---------+------------------+
- === CASE 3 ===
- allocation:
- +----+------+----------+---------+------------------+
- | id | week | employee | project | work_description |
- +----+------+----------+---------+------------------+
- | 1 | 1 | 1 | 1 | d1 |
- | 2 | 1 | 1 | 2 | d2 |
- +----+------+----------+---------+------------------+
- +-------------+-----------------+ +-------------+------------------+
- | | week 1 | | | week 1 |
- +-------------+-----------------+ ===> +-------------+------------------+
- | Ivan Petrov | Drive, Essence | | Ivan Petrov | Essence, AdWords |
- +-------------+-----------------+ +-------------+------------------+
- Delete record:
- +----+------+----------+---------+------------------+
- | id | week | employee | project | work_description |
- +----+------+----------+---------+------------------+
- | 1 | 1 | 1 | 1 | d1 |
- +----+------+----------+---------+------------------+
- Add record:
- +----+------+----------+---------+------------------+
- | id | week | employee | project | work_description |
- +----+------+----------+---------+------------------+
- | 3 | 1 | 1 | 3 | NULL |
- +----+------+----------+---------+------------------+
- Проблема в том, что в case2 и case3 теряется work_description. Использовать в case2 UPDATE вместо DELETE+ADD — не вариант, поскольку вместо одного AdWords может быть выбранно несколько проектов (как в case3). И тут уже ставить для всех записей work_description = d1 неправильно, т.к. в удаленных записях может быть и d1, и d2.
Add Comment
Please, Sign In to add comment