Inside MySQL 5.7 onwards until version 8; we are already able to use attributes for data of type JSON
Like this:
CREATE TABLE profile(
id BIGINT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50) UNIQUE NOT NULL,
attributes JSON NOT NULL
);
Later to do the insertion of data, we do the following
INSERT INTO profile(name, attributes)
VALUES
('alfred', '{"data": {"backend": true, "frontend": "maybe"}}')
Some functions like JSON_EXTRACT()
allow me to read the data of type JSON
in this way
SELECT name, JSON_EXTRACT(attributes, '$.data') AS Data FROM profile;
If for example we want to read the value of a specific key of our JSON structure we can do the following
The following syntax is the equivalent of
JSON_EXTRACT
has the same functionality but the structure is shortened; another detail is that for example
->>
helps remove the quotes from the text strings that result from the values ->
shows the result but includes the quotation marks in the text string
SELECT name, attributes- > '$. data.backend' AS Data FROM profile;
However, the previous thing follows under the slogan of using SQL
although the JSON_FUNCTIONS()
allow to operate the data with greater flexibility
Here the source: link
But the question is this:
Can I create a documentary database as allowed by, for example, MongoDB?