php - How is best to setup MySQL Relational Database? -
i've been working on improving ticket system made sometime ago , don't know best way store ticket updates. background- each ticket can updated text, status can updated , can assigned other people.
the tickets table looks this:
tickets: |tk_id|tk_status|tk_opened_by|tk_assigned|tk_room|tk_problem|tk_date|tk_time| |-----|---------|------------|-----------|-------|----------|-------|-------|
currently when ticket updated (either comment, status change or assignment) different tables used this. follows:
tk_update: |update_id|tk_id|user_id|comment|date|time| |---------|-----|-------|-------|----|----| tk_status: |status_update_id|tk_id|user_id|status|comment|date|time| |----------------|-----|-------|------|-------|----|----| tk_assign: |assign_id|tk_id|user_id|assigned_to|comment|date|time| |---------|-----|-------|-----------|-------|----|----|
this current set means pulling data 3 tables ticket , ordering them before displaying data on webpage. i'm thinking of changing setup follows:
tickets: |tk_id|tk_status|tk_opened_by|tk_assigned|tk_room|tk_problem|tk_date|tk_time| |-----|---------|------------|-----------|-------|----------|-------|-------| tk_updates: |update_id|tk_id|user_id|assigned_to|status|comment|date|time| |---------|-----|-------|-----------|------|-------|----|----|
that way there 1 table containing of updates. concern when comment update added status , assigned_to data have duplicated. there better ways of doing this?
thanks in advance!
user_id
,assigned_to
,status
can moved tickets
table shows current status of ticket. also, instead of tk_date
, can tk_opened_date
, , tk_updated_date
.
update_id
can primary key auto increment tk_updates
table keeping tk_id
foreign key. instead of columns assigned_to
/status
/, can have columns assigned
, status
can updated every change in of these values.
this table show history of ticket.
example:
tickets: |tk_id|tk_status|tk_opened_by|tk_assigned|tk_room |tk_problem|tk_opened_date|tk_updated_date| |-----|---------|------------|-----------|--------|----------|--------------|---------------| |123 |closed |john |wren |somedata|somedata |01/08/2016 |08/08/2016 | tk_updates: |update_id|tk_id|user_id|assigned|status |comment |date |time | |---------|-----|-------|--------|----------|-------------------------|----------|--------| |1 |123 |aaa |null |open |opened ticket |01/08/2016|00:00:00| |2 |123 |aaa |john |open |ticket assigned john |01/08/2016|00:00:00| |3 |123 |aaa |john |inprogress|now in inprogress |01/08/2016|00:00:00| |4 |123 |bbb |wren |inprogress|john assigned wren |01/08/2016|00:00:00| |5 |123 |bbb |wren |closed |fixed, closing |08/08/2016|00:00:00|
every ticket have 1 row current status , details in updates
table.
whenever there update, new row has inserted in updates
table. can have trigger update values of assigned_to
/status
/tk_updated_date
in ticket
table whenever there new row insert in updates
table.
Comments
Post a Comment