Answer the question
In order to leave comments, you need to log in
How to organize the storage of multiple tags in the database?
Task: There is a post with a tag. Search through a DB on tags leaves through the table of the intermediary.
The basic solution to the problem is the implementation of the form:
CREATE TABLE questions (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
url TEXT NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE tags (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
tag VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE questions_tags (
question_id INT UNSIGNED NOT NULL REFERENCES questions,
tag_id INT UNSIGNED NOT NULL REFERENCES tags
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question