Column database

I have a sales database where I want to get customer information based on a selection of these categories. I have about 15 categories, and my customer database is 5 million records. Each product may fall into more than one category. I need to get the customer name based on the selected category. Is it the best approach to put all these categories in columns or create a separate table for the product and category, and then the inner join? I want in terms of performance that fits better.

Approach 1:

option1 here 1 says that the product is under this category.

Approach 2:

approach2

+5
source share
1 answer

The second approach ( Approach 2 ) is a much better solution, rather than creating a separate table, because there is no need for each product to have all the categories in the approach to the one you reserve, creating separate columns, even if the category exists or not, and what if in the future, if one category is enlarged, you will have to change the current table structure, and this will not be an easy task.

Yes Join will be a little slow, but if you create the index correctly, it will work much better.

+2
source

Source: https://habr.com/ru/post/1243632/


All Articles