简体   繁体   中英

Database design for 2 tables which are related by an id

I am currently developing a tool which has the following tables and the respective columns.

Budget             Category          Transactions
budget_id          category_id       transaction_id
category_id                          category_id

Currently we are mapping the records of Budget to Transactions using category_id. But we have a glitch in the design. If two budget items have the same category_id, the transactions get mapped to both the budget. How can I have a design which maps the transactions items to the budget items in a one to one fashion but still keeping the loose coupling?

Budget             Category          Transactions
budget_id          category_id       transaction_id
category_id                          budget_id   

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