简体   繁体   中英

Data Logical organization

I have two tables: counterparties and customers. And both have an address field. I don't know, would it be better if I create third table "addresses"?
The first way:

Counterparty

  • id
  • name
  • city
  • streetname
  • room

Customer

  • id
  • firstName
  • lastName
  • city
  • streetname
  • room



The second way:

Counterparty

  • id
  • name
  • addressID

Customer

  • id
  • firstName
  • lastName
  • addressID

Address

  • id
  • city
  • streetname
  • room

What is better way?

The first solution is better, unless either:

  1. you have customers which are also counterparties (but then you should change the whole schema design), or
  2. several customers and/or counterparties have the same address (for instance they are in the same building).

There are no other reasons to choose the second solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM