D
D
Denis Safronov2015-02-19 21:57:11
Design patterns
Denis Safronov, 2015-02-19 21:57:11

Storing the article in the database. Which way to choose?

All good health!
There is a project that is planned to be resurrected. Not a highload, of course, but there are hopes for a middle load.
There are no deadlines and deadlines, so you can safely work out long-term investments in the quality of the code and architecture.
And then the question arose, how best to store articles. I'm torn between three options:
1. The "content" field contains all the text. Somewhere in the text the tag "" is inserted. Everything is selected from the database in its full form, and then it is cut off to this tag in the View.
2. Two separate fields - "announcement" and "body". In the "announcement" - the beginning of the article, in the "body" - the continuation.
3. Two separate fields - "announcement" and "content". In the "announcement" - a teaser for the article, in the "content" - the text.
That's all I think, to which option to lean. In terms of implementation, everything is simple. But what will happen in the future?
Share your experience, ladies and gentlemen, be so kind.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Cheremisin, 2015-02-19
@leahch

Of course, the third one, since the announcement and the text are different things, well, absolutely. Moreover, there could be two announcements, the second for the mobile version.

D
Dmitry, 2015-02-20
@hsc

The first one is definitely bad: a double (at least) large sample, from which only part of the information is needed at each stage. Conclusion: extra backend resources for cutting and processing, poor database cache, high traffic between the database and the backend.
The second and third have the right to life) If you want to make an analogue of habrakat, then the second and third are suitable, but I would choose the third one so that at any time you can get by with one sql query.
But, in fact, this has almost nothing to do with performance)

D
Dmitry, 2015-04-07
@seqular

Third option. The announcement will not always be the beginning, sometimes it will have to be rewritten. It happens that they send articles with images / tables at the beginning. Or sports scores. There is no need to include them in the announcement, but they come first.
At the filling stage, you can offer to auto-fill the announcement field for the first few offers (by default), but this field should definitely be separate.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question