K
K
Konstantin2014-01-09 11:16:10
MySQL
Konstantin, 2014-01-09 11:16:10

What would be the optimal table structure in my case?

Are there best practices on the structure of tables in terms of extensibility / performance for the following task:
There is a table of records (posts): id, datetime, title, text
Hashtags (#tag, #othertag ... etc.) are extracted from the text line
. entries can be attached links to media content - photos, videos. Such "attaches" can be from 1 to ... 100 for example.
Question: how to store all this?
1. Attachments in a separate table and attached by record id or in some other way?
2. Hashtags are also a separate table, or better, a simple enumeration in a separate line of the table of the entry itself.
Which is more economical in terms of database load when displaying lists of posts / searching by posts / searching by hashtags? Are there standard solutions of such a structure?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vit, 2014-01-09
@KGBelyaev

Attachments in a separate table and attach by record id or something else?

If attachments are specified once and for all, then it does not matter. And if then, for example, you need to edit or delete some individual attachments, then definitely in a separate table. Yes, and the rules of normalization, if you follow, it is better in a separate one.
A separate table, indexed by hashtag. If you specify them in the TEXT field by listing them, you will not be able to effectively search for hashtags. MySQL does have full-text indexes, but I don't recommend using them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question