We have high traffic NEWS websites, I want to add a feature that every user can search through over all content of site, such as news
, polls
, comments
, galleries
,etc . Each of contents type has its own table(s).
I decided to create a table that holds all of contents from all types:
CREATE TABLE full_text_search
(
master_id INT NOT NULL,
content_text TEXT NOT NULL,
PRIMARY KEY ( master_id )
);
I generate a unique number as master_id
for each content of all types to identify each content_text
in full_text_search
table.
for example:
News table:
+----+-------------+---------+---------+----------+------------+
| id | news_title | lead | subtitle| content | master_id |
+----+-------------+---------+---------+----------+------------+
| 1 | sometitle |some lead| subtitle|content 1 | 3 |
| 2 | some title |some lead| subtitle|content 2 | 5 |
+----+-------------+---------+---------+----------+------------+
article table:
+----+-------------+---------+------------------+---------+------------+
| id | title | author | short description| content | master_id |
+----+-------------+---------+------------------+---------+------------+
| 1 | sometitle | someone | very short desc |content1 | 1 |
| 2 | some title | otherone| some short desc |content2 | 4 |
+----+-------------+---------+------------------+---------+------------+
As you can see master_id
is unique between above tables. When ever a new content from each type inserted, also I should INSERT
it in to full_text_search
table.
QUESTIONS
- For many inserts for a day(about 3000 from all types), is it a good solution or it is anti pattern?
- Is it better choice if I separate this table from my other tables, and put it in any other DB such as other RDBMS or NoSQLs?
- Any other solutions?
full_text_search
-table, how will you identify the correct result with the correct type and id?