Workflow definitions (the .xoml xml file) are stored in SharePoint on the site. There are two locations:
When viewing the workflow gallery / manage workflows / preview a workflow, the hidden library called NintexWorkflows is read from. This is where we keep the most recently saved version of a workflow definition. It is the 'master' copy of the workflow. The library does not have versioning enabled. This is the location that the workflow designer will read and write to. Also previewing the workflow from the workflow gallery will read from here. As there is no versioning, these views have to read from the latest.
Then there is the /Workflows/NintexWorkflow library, which is where a workflow is placed when it is published, where the SharePoint workflow engine takes over control. SharePoint Designer workflows are also published to the /Workflows folder. This does have versioning enabled. No workflow definition is stored in the database. The database will have some records for every instance that is started, which stores a reference to the version of the workflow that was started. When a runtime progress view is rendered, the version number is used to query the correct definition from the Workflows/NintexWorkflow library.