Answer the question
In order to leave comments, you need to log in
How to organize a database?
Hello, how to properly organize the database. I will have a table in which promotional codes will be stored, their number can be very large, and there will be 4 types of promotional codes, how to organize their storage?
I thought to make 4 tables for 4 types of promotional codes, and add a number to the end of the protocol, which will indicate the type of promotional code. But if I need to pull out all promotional codes by a certain attribute, for example user=99 from all tables, then there will be 4 queries, as I understand it, this will not be very good, what should I do in my situation?
Answer the question
In order to leave comments, you need to log in
I would make one table with promotional codes and think over which indexes would be needed based on possible use cases.
One table because now you have 4 types, and then there may be more of them and for this you will have to add new tables and rewrite queries?
In addition, many tables will complicate queries, especially where it will be necessary to build reports.
To prevent the table from growing too much, you can provide a lifetime for promotional codes and delete or transfer expired ones to an archive table.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question