我正在设计一个用于存储餐馆数据的表格
问题是存储的数据太多。
我看起来是最好的结构方式
我想避免使用带有一堆列的表,因为它看起来像是糟糕的设计(是吗?)
数据的一些片段:
- 餐馆名称
- 地址
- 城市
-State
-Zip
-country
-Neighborhood / Tag
-Cuisine
..
..
-Policy
以下是解决问题的方法:
选项1:
将所有数据放入1个表格中。
+---------+----------+----------+-------------------------+
| res_id | option1 | option2 | option3 | .. | option20 |
+---------+----------+---------+---------+----+----------+
| | | | | | |
+--------------------------------------------------------+
选项2
将数据拆分为多个表
+---------+----------+----------+----------------------+
| res_id | option1 | option2 | option3 | option4 |
+---------+----------+---------+---------+------------+
| | | | | |
+---------+---------+----------+---------+------------+
+---------+----------+----------+----------------------+
| res_id | option5 | option5 | option6 | option7 |
+---------+----------+---------+---------+------------+
| | | | | |
+---------+---------+----------+---------+------------+
选项3
使用多对多关系
restaurant
+---------+----------+----------+
| res_id | name | location |
+---------+----------+---------+
| 1 | blah | blah |
+---------+---------+----------+
| 2 | blah | blah |
+---------+---------+----------+
info
+---------+----------+
| info_id | key |
+---------+----------+
| 1 | info1 |
+---------+---------+-
| 2 | infor2 |
+---------+---------+
restaurant_info
+---------+----------+----------+
| res_id | info_id | value |
+---------+----------+---------+
| 1 | 1 | val |
+---------+---------+----------+
| 1 | 2 | val |
+---------+---------+----------+
感谢任何建议