More efficient to have more columns or more rows?

I am redesigning a database that can contain a lot of data. I have the opportunity to either include several columns in the database, or use many rows. This is probably easier if I made some kind of plan below:

item_id | user_id | title | description | content | category | template | comments | status
-------------------------------------------------------------------------------------------
1       | 1       | ABC   | DEF         | GHI     | 1        | default  | 1        | 1
2       | 1       | ZYX   |             | QWE     | 2        | default  | 0        | 1
3       | 1       | A     |             | RTY     | 2        | default  | 0        | 0
4       | 2       | ABC   | DEF         | GHI     | 3        | custom   | 1        | 1
5       | 2       | CBA   |             | GHI     | 3        | custom   | 1        | 1

Compared to something in the following structure:

item_id | user_id | attribute   | value
---------------------------------------
1       | 1       | title       | ABC
1       | 1       | description | DEF
1       | 1       | content     | GHI
...     | ...     | ...         | ...

I can create additional attributes in the future (50 for arguments) - so when using multiple columns there can be many empty cells. Attribute names will be used, if possible, for different types of content — for example, a blog post, event, and gallery — titlewill be easily reused.

, : - . , , .. , , app/API ( ).

,

MySQL ( , ), .

+4
3

, .

, , .

, , , , , .

, , , , , , .

+1

, mysql , . , cols - (, ).

, , / , . , , .

, , cols . - "" , , , , .

+1

, , , . , - . , Reddit , , / . , .

NoSQL, , .

Google , , , , , , , .

+1
source

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


All Articles