I want to model an assembly line in SQL Server. This object would progress through a linear set of steps. Each step would have a linear set of statuses: Waiting, In Process and Completed. Which is the best approach for capturing data about a change in step and/or state? Insert one record for the object and update a step field and a status field when these properties change? Or, should I insert a new record every time the object progresses to a new step or changes a status in this step? I have tried the latter and I found the SQL queries required to be complicated.
If one object has only one status, I suggest the status field approach: easier to manage, faster to query. I used this solution in some applications and I haven't seen any problems.
This belongs on Stackoverflow and I've voted to close it as such. having said that, I will say that I've designed and implemented systems like this (an inventory system for a motorcycle parts manufacturer being the most recent) and the flexibility that a "transactive" model (i.e. the "insert a new record" choice) is wonderful and its utility far outweighs any "complexity" in the queries. Using the "MAX" and "MIN" aggregate functions against the datetime fields that identify the time an operation happend along with the "TOP..." qualifiers on SELECT statements can make the complicated queries much less complicated.
Workflows in general are best modeled with queues. See Building the MSDN Aggregation System, and I know of some real factory assembly lines that also use queues.
You could do both: maintain a "current" state for each object and a history of progression in case you need to see what path the object took through the queue and how long it took in each one. If each state requires more state information (that is different for each state) then you will need to create separate tables for each grouping of state information or, if you can represent it as a set of key-value pairs, create a simple property table.
Here's a rough example of a table layout:
Object Table:
Id, Name, Description, State
ObjectHistory Table:
Id, ObjectId, Timestamp, State
Properties Table:
Id, ObjectId, Name, Value
--or--
State1Info Table
Id, ObjectId, ...
State2Info Table
Id, ObjectId, ...