Should I use flat tables or a normalized database?

前端 未结 7 979
南方客
南方客 2021-02-19 03:39

I have a web application that I am currently working on that uses a MySQL database for the back-end, and I need to know what is better for my situation before I continue any fur

7条回答
  •  悲哀的现实
    2021-02-19 04:27

    The way I would handle this is to use a normalized, extensible "Property" table, such as below:

    Table: FormProperty
     id: pk
     form_id: fk(Form)
     key: varchar(128)
     value: varchar(2048)
    

    The above is just an example, but I've used this pattern in many cases, and it tends to work out pretty well. The only real "gotcha" is that you need to serialize the value as a string/varchar and then deserialize it to whatever it needs to be, so there is a little added responsibility on the client.

提交回复
热议问题