Database Model for Live and Draft Data

I discussed the best way to store a live dataset and a dataset project in a database. The live version is displayed on the website, and the project version works until it is ready for use. The model is relational and consists of many tables.

My current method is to have 2 databases, one for drafts and one for life. When you advertise data for life, SQL simply copies the data from the db project to live db.

This is good, but a little slower and seems dirty. And often, SQL must consider both sets of tables.

Another way would be to make the Live indicator as part of the key of each table, so I can keep both live and drafts in one table - and update the indicator so that the data is live. - I really do not sell on this idea.

  • DBMS is Sybase.

I would be grateful if anyone has any other suggestions.

Um

+5
source share
4 answers

have one table

DataTable
    DataKey
    DataMode
    Data...

PK - DataKey + DataMode
control restriction: DataMode IN ('L', 'D') - fat or draft

DataMode = 'D' --draft
, INSERT SELECT, DataMode = 'L'
DataMode = 'D' DataMode = 'L', .

, WHERE DataKey = @x AND DataMode = @Mode

, ( , , ?), :

    DataStatus  --'A'ctive 'D'eleted

, sql "L", "D'".

+2

, .

, , , . , <= ( ). , , , , .

, (), . , , , .

+1

, . . , - NULL, . , .

, . , , , DB, .

0

, , blelean is_live - N. , Y.

Having this work will force you to look at all the queries so that they filter out drafts when they should not be seen, but save you from having to maintain two parallel tables with the same formats and all that.

0
source

All Articles