Answer the question
In order to leave comments, you need to log in
MySQL: How rational is this approach to data storage?
Every day the program collects data and puts it in the database. Just two columns: date | data
11/12/2014 | Sky, Air, Water, Stone, Sky, Sky
Next, I need to process and choose the most common words.
Hence two questions:
Does it make sense for me to carry out statistical processing before insertion and glue the words in with the number of repetitions, i.e.
November 12, 2014 | Sky:3, Air:1, Water:1, Stone:1
Next, I need to somehow be able to conveniently request statistics by day. Hence the question. Do I need to convert all words into columns in order to write popularity for each? This is very inconvenient. when there are 5 words, it's ok, but what if I have about 1000 words. What now for each column to create?
How to make it prettier? How to store everything?
Answer the question
In order to leave comments, you need to log in
Well, for example, two tables: "date | id_words | quantity" and "id_words | word".
Which indexes to impose is a topic for independent study.
Initially, the data is incorrectly organized. Need one table
CREATE TABLE `table` (
`date` DATE,
`word` VARCHAR(64),
`count` INT,
PRIMARY KEY(`date`, `word`));
INSERT INTO `table` (`date`, `word`, `count`)
VALUES (CURDATE(), :word, 1)
ON DUPLICATE KEY UPDATE `count` = `count`+1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question