寻求帮助来制定订阅服务架构

发布于 2024-11-05 21:50:19 字数 401 浏览 0 评论 0原文

我发现很难决定每月订阅服务的模式。特别是,如果我的信用卡表应该与客户或订阅相关。

我目前拥有的表如下:

   users
      id
      other fields.

   addresses
      id
      userid
      other fields

   subscriptions
      id
      userid
      other fields

   cards
      id
      userid
      last4digits

一个用户只能有一个订阅。目前,仅接受信用卡作为付款方式。然而,这种情况未来可能会改变。我的架构很简单,但我担心如果添加更多付款类型,将来更改我的设置会很痛苦。

您能给我一些建议吗?

I'm finding it difficult to decide on a schema for a monthly subscription service. In particular, if my the credit cards table should be related to the customer or to the subscription.

The tables I currently have are the following:

   users
      id
      other fields.

   addresses
      id
      userid
      other fields

   subscriptions
      id
      userid
      other fields

   cards
      id
      userid
      last4digits

A user can only have one subscription. For now, only credit cards are accepted as a form of payment. However, that could change in the future. My schema is simplistic, but I'm afraid my setup will be a pain to alter in the future if more payment types are added.

Can you provide me with some advice please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱殇璃 2024-11-12 21:50:19

您的数据库设计应该考虑您想要对数据执行什么类型的查询,但是,在不了解更多信息的情况下,如何引入 Payments 表:

Clients 1..* Cards

Cards 1..* Payments

Payments 1..* Subscriptions

这样将来您可以轻松添加其他付款类型,例如添加:

Clients 1..* PaypalAccounts

PaypalAccounts 1..* Payments

另外,我我假设可以为多个订阅收取一笔费用。

Your database design should consider what types of queries you will want to execute against the data, however, without knowing more, how about introducing a Payments table:

Clients 1..* Cards

Cards 1..* Payments

Payments 1..* Subscriptions

This way in the future you can easily add other payment types, e.g. add:

Clients 1..* PaypalAccounts

PaypalAccounts 1..* Payments

Also, I'm assuming a payment can be taken for more than one subscription.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文