Database design: how to simulate a table?

Let's say I want every user of my application to be able to specify the number of columns and rows, and then assign specific values ​​in each cell. Basically, I want them to be able to create tabular data - for example, a spreadsheet.

A good example is the appointment of seats in a theater. Perhaps a place in the cinema can be represented in the grid. Some cells will have no places, some will have places. Some places can be for VIP, some for disabled people, some for regular customers.

How do I simulate such information?

+4
source share
2 answers

Save the number of rows and columns for each "sheet" in one table, and the data in another. The latter will look like

rownum | colnum | value 

If you are specially writing an application for theaters, just add the necessary properties:

 rownum | colnum | sold (bool) | available (bool) | is_vip (bool) 
+1
source

I’m personally here, as I would imagine it:

  • String (integer)
  • Column (integer)
  • Value (string or something really)

And then I will make a primary key (Row, Column) and, possibly, additional indexes as needed.

0
source

All Articles