如何在MySQL中创建拆分账单的数据库结构?

时间:2018-12-03 06:09:06

标签: mysql sql

我有一个事务表,其结构如下:

| transaction_id | customer_id | amount | transaction_type_id | status |
transaction_id => is the id of the transaction
customer_id => is the customer id who did the transaction
amount => Total transaction amount
transaction_type_id => Type of transaction 
status => status of the transaction => pending, complete, canceled

我想为我的程序创建拆分账单功能,该功能的工作方式如下:

  1. 客户输入要拆分的账单总额。
  2. 客户添加另一个客户(n个客户)以拆分账单,并指定金额。
  3. 将为拆分账单中的所有客户进行交易,状态为待定并指定了金额。
  4. 其他客户将收到拆分账单请求,以拒绝或接受
  5. 如果其中一位客户拒绝了拆分账单请求,则交易将被取消,但是如果所有客户都接受了该请求,则交易状态将会完成

到目前为止,我已经通过创建主split_bill表和split_bill_request这样来解决该解决方案:

split_bill
split_bill_id|transaction_ids | initiator | total_amount
split_bill_id => id of the split bill
transaction_ids => All the customer transaction id separated by comma
initiator => the customer_id who initiate split bill
total_amount => total of the bill

split_bill_request
split_bill_request_id | split_bill_id | customer_id | status
split_bill_request_id => id of split bill request
split_bill_id => id of the split bill
customer_id => id of the customer who receive split bill request from initiator
status => status of the request pending,accept,reject

我不知道这是否是正确的方法,您能否建议另一种方法,因为我对split_bill表中的transaction_ids或执行此操作的有效方法有疑问,并且我没有权限修改交易表?

0 个答案:

没有答案