Answer the question
In order to leave comments, you need to log in
How to design a word database?
It is necessary to store a set of words / phrases in the database, while being able to conveniently select using php / react js and update in the same way, what is the best way to do this? There will be no more than 100-150 words
In my head, the idea is to create a varchar cell and write everything into it, separated by commas. (then it is necessary to select it all more conveniently and push it into one array)
Answer the question
In order to leave comments, you need to log in
| words |
+ ------ +
| lala |
| ... |
So, a cell, yes, Varchar, store each word separately, it’s not convenient to select through a comma, read about normalization
The idea in my head is to create a varchar cell and write everything into it, separated by commas.
CREATE TABLE words (
word_id INT AUTO_INCREMENT PRIMARY KEY,
word VARCHAR(255) UNIQUE NOT NULL
);
CREATE TABLE phrase (
phrase_id INT NOT NULL,
FOREIGN KEY (phrase_id) REFERENCES phrases (phrase_id),
word_id INT NOT NULL,
FOREIGN KEY (word_id) REFERENCES words (word_id),
word_position INT,
PRIMARY KEY (phrase_id, word_position)
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question