You are building an application that uses a database. For example, it is a marketing/sales software. The application allows user to create scenarios, one user may choose a different path to improve the company's sales, other user may choose another path. Each user's scenario is saved in the database, they can load their scenarios from database whenever they want and continue working on it.
The question is: how does the application alter the database? For example, there is a table "sales". User 1 has a scenario, and he has different values in "sales" table, and user 2 may have completely different values.
Would application create different copies of sales table for each scenario? Such as sales_scenario_1
and sales_sceneario_2
?
How are these kind of applications built?
Asked
Active
Viewed 496 times
0

alwbtc
- 28,057
- 62
- 134
- 188
-
I would never ever make changing the database model part of the normal application usage. – Stefan Steinegger Mar 17 '14 at 10:06
-
1From the brief description, it does seem that you will need to throw a "scenario" id into your tables and queries. – Darius X. Mar 17 '14 at 14:26
-
Won't that make the tables too big? If there's 2000 rows for 1 scenario, then there would be 10000 rows for 5 scenarios – alwbtc Mar 18 '14 at 10:50
1 Answers
1
You create a table with dynamic values:
sales
ID,
...
sales_properties
sales_FK,
name,
value
I would never change the database structure as part of normal application usage. You wouldn't be able to handle the different database models.

Stefan Steinegger
- 63,782
- 15
- 129
- 193
-
What do you mean with dynamic values? do you add an extra column to each table that holds user's or scenario's ID number? – alwbtc Mar 17 '14 at 11:11
-
You probably need a table that stores the scenarios and a list of property names that are available. The sales_properties holds the values. You probably need a scenario id on some tables. This is all application specific. – Stefan Steinegger Mar 18 '14 at 06:32