1
vote
How to deal with invoices that reference products that don't exist any more?
1: What is the best way to store data of a product in invoice? Is it by bringing the id of the product, or by bringing all info related to the product? Actually is it a good practice to store id of ...
1
vote
Accepted
Get the difference for a column value by all its previous rows data
Something like this, may be?
sum(case transaction_type when 'debit' then -1 else 1 end * amount)
over (partition by vault_id order by id rows unbounded preceding and current row)
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
database-design × 5949mysql × 1383
sql-server × 819
postgresql × 690
schema × 413
normalization × 393
performance × 332
erd × 306
foreign-key × 210
relational-theory × 199
database-recommendation × 150
primary-key × 148
oracle × 140
index × 136
table × 115
data-warehouse × 106
nosql × 104
mongodb × 97
query-performance × 96
best-practices × 96
database-diagrams × 96
optimization × 93
sql-server-2008 × 92
constraint × 87
subtypes × 79