Dwix
Dwix

Reputation: 1257

Multiple Many-To-Many relationships scenario in MySQL

I'm a beginner in SQL and Database management, I have an idea that I don't know how to model into database tables.

I have these tables : users, orders, bills, lessons, tickets, coaches.

So when a user buy a ticket that costs 6$ for a specific lesson, the coache who owns the lesson will get 3$.

Do I need another bills table for the coaches? or I can use the same bills table to register their gains from the purchased lessons? I really have no idea how to achive my List of ideas above, sorry.

For now I've just managed to do this, I don't know how to complete the rest of the DB.

|bills|<--|orders| *<------ |users|
            |
            v
            *
        |order_lesson|
            *
            /\
            |
        |lessons| *<----- |coaches|

I can't ask you for a complete answer, but I really need some explication or guidance.

Upvotes: 0

Views: 69

Answers (1)

Matthew
Matthew

Reputation: 850

From what I can tell the ticket is no different then a regular order and can be placed with the orders as the only difference is the money the coach gets. So maybe just a column in the orders table would signify the type of order.

 |bills|<--|orders|<----|users|
                / \
                 |
              |lessons|<---|coaches|

Upvotes: 1

Related Questions