How to create and manage a MySql database to solve a simple FK problem
Posted on 2013-05-13
I am trying to build a small app to understand a bit of programming but I'd need a bit of help to understand how to correctly arrange this:
- id_customer // primary key, autoincrement
- name // a varchar
- group // a varchar
- id_payment // primary key, autoincrement
- month // a varchar
- id_customer_fk // foreign key reference to a customer (TAB_CUSTOMER)
- paid // int with money paid
I have prepared a page where the user can change the year and click on months to change the state to paid or not paid.
Is my database correctly designed?
What kind of action should I take when I insert a new user?
I don't know how to handle the payments table...
In my idea I could automatically create a few years of future use for every new user inserted and set all the months' payment to zero.
But I think that there must be better ways and I'd like to ask experts so I learn the best way to handle this.
I am not really looking for code (even if it's welcome), just for problem analysis and ideas.