Say I want each user of my application to be able to specify a number of columns and rows, then assign certain values within each cell. Basically, I want them to be able to create tabular data -- like a spreadsheet.
假设我希望我的应用程序的每个用户能够指定多个列和行,然后在每个单元格中分配特定值。基本上,我希望他们能够创建表格数据 - 就像电子表格一样。
A good example would be the seating assignments within a theater. A theater's seat can probably be represented within a grid. Some cells will not have seats, some will have seats. Some seats may be for VIP, some for the disabled, some for regular customers.
一个很好的例子是剧院内的座位分配。剧院座位可以在网格中表示。有些牢房没有座位,有些座位有座位。有些座位可能是VIP,有些是残疾人,有些是常客。
How do I model such information?
我该如何建模这些信息?
2 个解决方案
#1
1
Store number of rows and columns for each "sheet" in one table, and the data in another. The latter would look like
在一个表中存储每个“工作表”的行数和列数,在另一个表中存储数据。后者看起来像
rownum | colnum | value
If you're specifically writing an application for theaters - just add needed properties there:
如果你专门为剧院写一个应用程序 - 只需在那里添加所需的属性:
rownum | colnum | sold (bool) | available (bool) | is_vip (bool)
#2
0
Me personally here's how I'd represent it:
我个人在这里是我代表它的方式:
- Row (Integer)
- Column (Integer)
- Value (String, or anything really)
价值(字符串,或任何真正的)
And then I'd make the primary key (Row, Column) and maybe additional indices as needed.
然后我会根据需要制作主键(行,列)和其他索引。
#1
1
Store number of rows and columns for each "sheet" in one table, and the data in another. The latter would look like
在一个表中存储每个“工作表”的行数和列数,在另一个表中存储数据。后者看起来像
rownum | colnum | value
If you're specifically writing an application for theaters - just add needed properties there:
如果你专门为剧院写一个应用程序 - 只需在那里添加所需的属性:
rownum | colnum | sold (bool) | available (bool) | is_vip (bool)
#2
0
Me personally here's how I'd represent it:
我个人在这里是我代表它的方式:
- Row (Integer)
- Column (Integer)
- Value (String, or anything really)
价值(字符串,或任何真正的)
And then I'd make the primary key (Row, Column) and maybe additional indices as needed.
然后我会根据需要制作主键(行,列)和其他索引。