设计地址和客户模型
当我设计地址和客户类(模型)时,我遇到了一个问题。
class Customer
(String) first_name
(String) last_name
(String) document_id
(String) phone
(String) email
(Address) contact_address
(Address) billing_address
class Address
(String) street
(String) block
(String) apt
(Location) location
class Location
(String) zip_code
(String) city_name
(State) state
(Country) country
class State
(String) name
(Country) country
class Country
(char[2]) tld
(String) name
但 State.country 中的信息会随着 Location.country 的增加而增加一倍。 然而,我无法想象不指定国家的情况。 否则,如果我从位置类中删除国家/地区字段,则从一个国家/地区获取所有位置对象会很奇怪。
我错过了什么吗?
怎么样:
class Address2
(String) street
(String) block
(String) apt
(String) zip_code
(String) city_name
(String) state
(String) country
但是我将丢失有关 tld 的其他信息,并且我将在 Location.state 和 Location.country 中存储重复的(未优化的)数据
I have encountered a problem, when I was designing an address and a customer classes (models).
class Customer
(String) first_name
(String) last_name
(String) document_id
(String) phone
(String) email
(Address) contact_address
(Address) billing_address
class Address
(String) street
(String) block
(String) apt
(Location) location
class Location
(String) zip_code
(String) city_name
(State) state
(Country) country
class State
(String) name
(Country) country
class Country
(char[2]) tld
(String) name
But information in State.country doubles with Location.country.
However I can't imagine a situation, of not assigning a country to state.
Otherwise if I drop country field from Location class, it would be odd to get all locations objects from one country.
Am I missing something?
How about:
class Address2
(String) street
(String) block
(String) apt
(String) zip_code
(String) city_name
(String) state
(String) country
However I will lose additional information about tlds, and I will store duplicated (not optimized) data in Location.state and Location.country
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么 Location 类别中需要一个国家/地区?
就像您可以从 state.countryId 检索 tld 一样,您可以从 location.stateId 检索国家/地区。
Why do you need a country in the Location class?
Just like you can retrieve the tld from state.countryId, you can retrieve the country from location.stateId.