mysql - redesigning my database -


on old web app had table following structure:
tools(id, name, abbreviation, width, height, power, type)

the thing need add history support tools. working scenario details of each tool can modified, , need keep track of changes. example, if need see details of tool date past, how can that?

how database have looks?

i keep same table, add dateeffective field, , create new row every time tool changes. when querying table, can version of tool @ given date using:

select * tools id=@id , dateeffective<@thisdate order dateeffective desc limit (0,1) 

edit may wish create field called toolversionid primary key.

edit 2 in response comment, how about:

select * tools t1 toolversionid in (select toolversionid                         tools t2                         t2.id = t1.id                         order t2.dateeffective desc                         limit (0,1)                        ); 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -