我在产品交货单上有两套输入-
information(required) - (country, state, city, zipcode, street, contact_no)
(country, state, city, zipcode, street, recipient name, contact_no)我需要一个高效、灵活的数据库模式,下面是我认为可能对我有用的内容:
user id, name, email
country id, country, iso_code
state id, state, country_id
city id, city, state_id
address_type id, type 1 required 2 optional
address id, street(null), city_id(null), state_id(null), country_id(null), type_id
recipient id, user_id, address_id, contact_no
alternate_recipient id, name, address_id, contact_no
delivery_info id, recipient_id, alt_recipient_id(null)
或者,我应该只使用两个单独的表来处理所需的和可选的数据集,还是说我可以选择呢?有没有更好的解决办法?
发布于 2020-02-10 03:52:11
在效率方面,通过对表进行拆分,您必须连接表以获得相关数据,这比拥有一个不需要担心的空值表的效率要低。如果稍后要提取数据,只需使用IFNULL并给它一个值。
发布于 2020-02-10 05:00:44
制作两个独立的表将帮助您使您的结构更加规范化,但您有基本的用户配置文件,因此您可以继续使用当前的结构本身。
https://stackoverflow.com/questions/60143774
复制相似问题