Recently we've started developing Github like organisation system for our service.
We have both free and payed plans.
There are users. Also there should be the owner for organisation and the owner has to register his credit card for the payed plan.
Owners can invite any users.
We cost each users and owners separately.
For example,
ManA registered with his email ManA@gmail.com ManA also opened up his organisation named "OrgA"with his email OrgA@gmail.com I'm struggling with how I can architect the table like Github.
I thought "Pivot table" would be great but it's okay as long as the email is the same. (ManA also opened up his organisation named "OrgA"with the same email as he uses for his personal account. ManA@gmail.com)
Payment info is also same as the email. ( Any users can register another billing info for his own organisations.)
I just wonder how I could implement the good entity relations.
NOTE: This is as the same as I posted on https://stackoverflow.com/questions/38096718/how-to-use-a-table-when-the-user-identifier-can-be-one-of-two-fields.
But maybe here is the right place to post, so as soon as I get some answers, I will delete posts in stackoverflow.
##### Update ######
Scenario
I am new to databsae design, and I decided to develop to make Github like organisation billing system. However I am having trouble modeling and normalizing it.
The databse is meant to store data about Credit card info (Actually it will be token though.), Users, Organization, Billing
Business rules
- A User can have multiple billing information
- A User can join any organizations
- A User can be an organizer.
- A User has to pay for his own usage.
- A User can separate his creditcard billing information
- An Organization always has an organizer
- An Organizer has to pay for usages made by users in the group
- An Organization has a name and an emai.
The issue
I'm struggling to apply any relations between tables efficiently. Also the problem is that if the credit_card has changed the billing history will be gone with this implementation. So I'd love to put Billing relations to Person & Organization, however it will be mess. Any ideas?