开发者

Database Design: how to model a table?

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 wi开发者_运维知识库thin 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.

How do I model such information?


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)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜