如何设计支付数据库?

发布于 2025-01-03 13:24:47 字数 465 浏览 0 评论 0原文

我正在编写一个程序来控制一所学校。 它更像是会员订阅模式。 学生申请课程,并且必须在学校日历定义的特定时间的剩余时间内支付月费。

根据具体情况,某些特定学生的铭文或月费可以减少。 一旦学生订阅课程,这将是定期付款, 学生可以支付部分费用。 此外,学生可以退出,再也不会回来。

我已经提供了类似这样的表格:

STUDENT
+id
+name

COURSE
+id
+name
+inscription_fee
+monthly_fee

SCHEDULED_PAYMENTS
+id
+student_id
+description
+amount

-LEDGER
+id
+student_id
+course_id
+amount

但是当我想知道学生支付了多少费用、每月应交费用等等时,我最终遇到了漫长而复杂的查询。

所以我问,这是为以下对象设计数据库的正确方法吗?付款?或者有更好的方法吗?

I'm writing a progam to control a school.
It's more like a membership subscription schema.
A student applies for a course, and will have to pay an inscription ad a monthly fee, for the rest of a specific time defined by school calendar.

Depending on each case inscription or monthly fees can be reduced for some specific student.
Once a student subscribe to a course, it will be a recurrent payment,
the student can make partial payments.
Also, the student can quit, and never come back.

I have come with something like tables this:

STUDENT
+id
+name

COURSE
+id
+name
+inscription_fee
+monthly_fee

SCHEDULED_PAYMENTS
+id
+student_id
+description
+amount

-LEDGER
+id
+student_id
+course_id
+amount

But I ended up with long complicated queries when I want to know what a student has paid, wich monthly fees are due, etc.

So I ask, Is this the right way to design a database for payments? or is there a better way?

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

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

发布评论

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

评论(2

甜中书 2025-01-10 13:24:47

我认为您所需要的只是您的学生表和课程表,然后是中间的链接表,以显示哪个学生正在学习什么

课程
+id, +姓名

课程
+ ID、+姓名、+费用、+每月费用

学生课程
+学生号
+Course_id

then

select *
FROM student
JOIN student_course on student.id = student_course.student_id
JOIN course on course.id = student_course.coruse_id
where student.name = ?

那么您就有学生的月费和每堂课的费用

I think all you need is your student table, and your course table, Then a linking table in between to show which student is taking what course

Student
+id, +name

Course
+id, +name, +fee, +monthly_fee

Student_course
+Student_id
+Course_id

then

select *
FROM student
JOIN student_course on student.id = student_course.student_id
JOIN course on course.id = student_course.coruse_id
where student.name = ?

Then you have both monthly fee and fee, per class for a student

蓝眸 2025-01-10 13:24:47

我将分类帐和预定付款放在一张表中。当付款到期时添加它,如果付款了则将其标记为已付款。但正如 @Marrgall 指出的那样,确实没有正确的方法来做到这一点,并且您会在现场发现很多冗长复杂的查询。所以你最好习惯它。

I'd put the ledger and the scheduled payments as 1 table. When a payment is due add it, and if it gets paid mark it as paid. But as @Marrgall pointed to there really is no right way to do it, and you' find LOTS of long complicated queries out in the field. so you may as well get use to it.

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