Three customer addresses in one table or in separate tables?

前端 未结 7 2251
慢半拍i
慢半拍i 2021-02-07 17:43

In my application I have a Customer class and an Address class. The Customer class has three instances of the Address class:

7条回答
  •  执念已碎
    2021-02-07 18:05

    In this case, putting each address field in a different row is not normalization. It's just table partitioning. The assumption that any schema with more tables is "more normalized" is wrong.

    Let's say we have these two alternative schemas in a database: 1) user: user_id, username, password

    2) user: user_id, password_id password: password_id, password

    Is (2) "more normalized" than (1)? No!

    In this OP's case, as long as: 1) we're treating the address as an atomic value, 2) the application only requires those three types of addresses.

    Then it is just as valid valid to store each address in a different column. The second solution does not decompose the addresses into its components (country, town, street, etc). Therefore it is not "more normalized" than the first one!

提交回复
热议问题