samedi 29 juillet 2023

Database design: How to assign different clients to varying number of films?

This is a purely design question: In my node.js app, registered clients (each having individual client_id) can buy access to: One film 10 of them 30 of them 150/all of them. The question is: how to deal with this? Using MySQL database, I am thinking what tables I should create to dealt with the fact that many clients can have different number of films assigned to them, while each film is different.

I thought of 2 solutions: first, let's make a huge table with 150+ columns, each representing individual film_id. Then, I can just 0/1 the column in a specific row to assign a film to a client, but then for 100 clients I would have 15000 cells in a single table? Quite large

Second idea was to create 4 tables, where 1st and 4th are pretty simple: If a user buys one film, assign that film's id to them, and if they buy all films, just note in the last table that they have unlimited access.

Aucun commentaire:

Enregistrer un commentaire