
{"id":2492,"date":"2018-07-23T13:13:57","date_gmt":"2018-07-23T12:13:57","guid":{"rendered":"http:\/\/dasini.net\/blog\/?p=2492"},"modified":"2019-04-02T10:12:37","modified_gmt":"2019-04-02T09:12:37","slug":"30-mins-avec-les-fonctions-json-de-mysql","status":"publish","type":"post","link":"https:\/\/dasini.net\/blog\/2018\/07\/23\/30-mins-avec-les-fonctions-json-de-mysql\/","title":{"rendered":"30 mins avec les fonctions JSON de MySQL"},"content":{"rendered":"<p><em><a href=\"http:\/\/dasini.net\/blog\/2018\/07\/23\/30-mins-with-mysql-json-functions\/\">Read this post in English<\/a><\/em><\/p>\n<p><em><span style=\"text-decoration: underline;\">Note<\/span>: L&rsquo;article suivant peut t\u2019int\u00e9resser \u00e9galement:\u00a0<a href=\"http:\/\/dasini.net\/blog\/2015\/11\/17\/30-mins-avec-json-en-mysql\/\" target=\"_blank\" rel=\"noopener noreferrer\">30 mins avec JSON en MySQL<\/a>.<\/em><\/p>\n<p><span style=\"text-decoration: underline;\"><em>Note<\/em><\/span> 2: Tu peux \u00e9galement manipuler tes documents JSON avec <a href=\"http:\/\/dasini.net\/blog\/2019\/04\/02\/mysql-json-document-store\/\" target=\"_blank\" rel=\"noopener noreferrer\">MySQL Document Store<\/a>.<\/p>\n<p>Comme tu le sais,\u00a0<a href=\"https:\/\/www.json.org\" target=\"_blank\" rel=\"noopener noreferrer\">JSON<\/a> (JavaScript Object Notation) est un populaire format d&rsquo;\u00e9change de donn\u00e9es. Depuis la version <strong>5.7<\/strong>, MySQL supporte un type de donn\u00e9es JSON\u00a0natif (au format interne binaire pour des raisons d&rsquo;efficacit\u00e9s), ainsi qu&rsquo;un riche ensemble de fonctions qui te permettront de manipuler dans tout les sens tes documents JSON.<\/p>\n<p>Soyons clair! Cet article n&rsquo;est pas une revue exhaustive des diff\u00e9rentes fonctions JSON impl\u00e9ment\u00e9es dans MySQL (<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json-functions.html\" target=\"_blank\" rel=\"noopener noreferrer\">RTFM! \ud83d\ude09<\/a>), mais plut\u00f4t une s\u00e9lection arbitraire de certaines d&rsquo;entre elles.<\/p>\n<p><em><span style=\"text-decoration: underline;\">Note<\/span>: Depuis MySQL 8 il est d\u00e9sormais possible de manipuler les documents JSON sans SQL (NoSQL) avec\u00a0<a href=\"https:\/\/www.mysql.com\/products\/enterprise\/document_store.html\" target=\"_blank\" rel=\"noopener noreferrer\">MySQL as a document store<\/a>. (Cette fonctionnalit\u00e9s\u00a0n&rsquo;est pas couverte dans cet article).<\/em><\/p>\n<p>Les exemples ci dessous sont r\u00e9alis\u00e9s sans trucage avec\u00a0<strong>MySQL 8.0<\/strong>.11, t\u00e9l\u00e9chargeable\u00a0<a href=\"https:\/\/dev.mysql.com\/downloads\/mysql\/\" target=\"_blank\" rel=\"noopener noreferrer\">ici<\/a>.<\/p>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json.html\" target=\"_blank\" rel=\"noopener noreferrer\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"JSON logo\" src=\"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/json_icon.png?resize=200%2C106\" alt=\"MySQL native JSON data type\" width=\"200\" height=\"106\" \/><\/a><\/p>\n<h2>JSON &#8211; Fonctions utilitaires<\/h2>\n<h3>JSON_PRETTY<\/h3>\n<p>Am\u00e9liorer la lisibilit\u00e9 avec <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json-utility-functions.html#function_json-pretty\" target=\"_blank\" rel=\"noopener noreferrer\">JSON_PRETTY<\/a><\/p>\n<p>Par d\u00e9faut, l&rsquo;affichage d&rsquo;un document JSON dans MySQL ressemble \u00e0 ceci :<\/p>\n<pre class=\"lang:mysql decode:true\" title=\"Display a JSON document\">SELECT doc FROM restaurants LIMIT 1\\G\n*************************** 1. row ***************************\ndoc: {\"_id\": \"564b3259666906a86ea90a99\", \"name\": \"Dj Reynolds Pub And Restaurant\", \"grades\": [{\"date\": {\"$date\": 1409961600000}, \"grade\": \"A\", \"score\": 2}, {\"date\": {\"$date\": 1374451200000}, \"grade\": \"A\", \"score\": 11}, {\"date\": {\"$date\": 1343692800000}, \"grade\": \"A\", \"score\": 12}, {\"date\": {\"$date\": 1325116800000}, \"grade\": \"A\", \"score\": 12}], \"address\": {\"coord\": [-73.98513559999999, 40.7676919], \"street\": \"West   57 Street\", \"zipcode\": \"10019\", \"building\": \"351\"}, \"borough\": \"Manhattan\", \"cuisine\": \"Irish\", \"restaurant_id\": \"30191841\"}<\/pre>\n<p>Tu peux avoir un affichage plus agr\u00e9able avec <strong>JSON_PRETTY<\/strong> :<\/p>\n<pre class=\"lang:mysql decode:true\" title=\"Pretty display a JSON document with JSON_PRETTY\">SELECT JSON_PRETTY(doc) FROM restaurants LIMIT 1\\G\n*************************** 1. row ***************************\nJSON_PRETTY(doc): {\n  \"_id\": \"564b3259666906a86ea90a99\",\n  \"name\": \"Dj Reynolds Pub And Restaurant\",\n  \"grades\": [\n    {\n      \"date\": {\n        \"$date\": 1409961600000\n      },\n      \"grade\": \"A\",\n      \"score\": 2\n    },\n    {\n      \"date\": {\n        \"$date\": 1374451200000\n      },\n      \"grade\": \"A\",\n      \"score\": 11\n    },\n    {\n      \"date\": {\n        \"$date\": 1343692800000\n      },\n      \"grade\": \"A\",\n      \"score\": 12\n    },\n    {\n      \"date\": {\n        \"$date\": 1325116800000\n      },\n      \"grade\": \"A\",\n      \"score\": 12\n    }\n  ],\n  \"address\": {\n    \"coord\": [\n      -73.98513559999999,\n      40.7676919\n    ],\n    \"street\": \"West   57 Street\",\n    \"zipcode\": \"10019\",\n    \"building\": \"351\"\n  },\n  \"borough\": \"Manhattan\",\n  \"cuisine\": \"Irish\",\n  \"restaurant_id\": \"30191841\"\n}<\/pre>\n<h3>JSON_STORAGE_SIZE<\/h3>\n<p>Renvoie le nombre d&rsquo;octets utilis\u00e9s pour stocker la repr\u00e9sentation binaire d&rsquo;un document JSON avec\u00a0<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json-utility-functions.html#function_json-storage-size\" target=\"_blank\" rel=\"noopener noreferrer\">JSON_STORAGE_SIZE<\/a>.<\/p>\n<pre class=\"lang:mysql decode:true\" title=\"Document size with JSON_STORAGE_SIZE\">SELECT max(JSON_STORAGE_SIZE(doc)) FROM restaurants;\n+-----------------------------+\n| max(JSON_STORAGE_SIZE(doc)) |\n+-----------------------------+\n|                         916 |\n+-----------------------------+\n\nSELECT avg(JSON_STORAGE_SIZE(doc)) FROM restaurants;\n+-----------------------------+\n| avg(JSON_STORAGE_SIZE(doc)) |\n+-----------------------------+\n|                    537.2814 |\n+-----------------------------+\n\nSELECT min(JSON_STORAGE_SIZE(doc)) FROM restaurants;\n+-----------------------------+\n| min(JSON_STORAGE_SIZE(doc)) |\n+-----------------------------+\n|                         255 |\n+-----------------------------+<\/pre>\n<p>Dans cette collection, le document le plus lourd fait 916 octets, le plus l\u00e9ger 255 et la taille moyenne de tout les documents est 537,2814.<\/p>\n<p><em><span style=\"text-decoration: underline;\">Note<\/span>: C&rsquo;est l&rsquo;espace utilis\u00e9 pour stocker le document JSON tel qu&rsquo;il a \u00e9t\u00e9 ins\u00e9r\u00e9 dans la colonne, avant toute <a href=\"https:\/\/mysqlserverteam.com\/partial-update-of-json-values\/\" target=\"_blank\" rel=\"noopener noreferrer\">mise \u00e0 jour partielle<\/a> qui aurait pu \u00eatre effectu\u00e9e par la suite.<\/em><\/p>\n<h2>Fonctions qui recherchent des valeurs JSON<\/h2>\n<h3>JSON_EXTRACT (-&gt;) \/ JSON_UNQUOTE \/ -&gt;&gt; operator<\/h3>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json-search-functions.html#function_json-extract\" target=\"_blank\" rel=\"noopener noreferrer\">JSON_EXTRACT<\/a> (or <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json-search-functions.html#operator_json-column-path\" target=\"_blank\" rel=\"noopener noreferrer\">-&gt;<\/a>) retourne des donn\u00e9es d&rsquo;un document JSON.<\/p>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json-modification-functions.html#function_json-unquote\" target=\"_blank\" rel=\"noopener noreferrer\">JSON_UNQUOTE<\/a>\u00a0supprime les guillemets des donn\u00e9es JSON et renvoie le r\u00e9sultat sous la forme d&rsquo;une cha\u00eene de caract\u00e8res utf8mb4.<\/p>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json-search-functions.html#operator_json-inline-path\" target=\"_blank\" rel=\"noopener noreferrer\">-&gt;&gt;<\/a> l&rsquo;op\u00e9rateur JSON \u00ab\u00a0<em>unquote extract<\/em>\u00a0\u00bb qui est un raccourci pour JSON_UNQUOTE(JSON_EXTRACT())<\/p>\n<pre class=\"lang:mysql decode:true \" title=\"Returns data from a JSON document with JSON_EXTRACT\">SELECT JSON_EXTRACT(doc, \"$.cuisine\") FROM restaurants LIMIT 1\\G\n*************************** 1. row ***************************\nJSON_EXTRACT(doc, \"$.cuisine\"): \"Irish\"\n\n\nSELECT doc-&gt;\"$.cuisine\" FROM restaurants LIMIT 1\\G\n*************************** 1. row ***************************\ndoc-&gt;\"$.cuisine\": \"Irish\"<\/pre>\n<p>Les deux requ\u00eates ci-dessus sont similaires.<\/p>\n<p>Pour avoir le m\u00eame r\u00e9sultat sans les guillemets utilise <strong>-&gt;&gt;<\/strong> ou <strong>JSON_UNQUOTE<\/strong>(<strong>JSON_EXTRACT<\/strong>()) :<\/p>\n<pre class=\"lang:mysql decode:true\" title=\"unquotes the extracted result with JSON_UNQUOTE &amp; JSON_EXTRACT\">SELECT JSON_UNQUOTE(JSON_EXTRACT(doc, \"$.cuisine\")) FROM restaurants LIMIT 1\\G\n*************************** 1. row ***************************\nJSON_UNQUOTE(JSON_EXTRACT(doc, \"$.cuisine\")): Irish\n\n\nSELECT doc-&gt;&gt;\"$.cuisine\" FROM restaurants LIMIT 1\\G\ndoc-&gt;&gt;\"$.cuisine\": Irish<\/pre>\n<p>Les deux requ\u00eates ci-dessus sont similaires.<\/p>\n<h3>JSON_CONTAINS<\/h3>\n<p>Recherche si la valeur de la cl\u00e9 correspond \u00e0 une valeur sp\u00e9cifi\u00e9e avec\u00a0<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json-search-functions.html#function_json-contains\" target=\"_blank\" rel=\"noopener noreferrer\">JSON_CONTAINS<\/a>.<\/p>\n<pre class=\"lang:mysql decode:true\" title=\"Whether a document contains Creole cuisine with JSON_CONTAINS\">SELECT count(*) \nFROM restaurants \nWHERE JSON_CONTAINS(doc, '\"Creole\"', '$.cuisine');\n+----------+\n| count(*) |\n+----------+\n|       24 |\n+----------+\n\n\nSELECT doc-&gt;&gt;\"$.name\" \nFROM restaurants \nWHERE JSON_CONTAINS(doc, '\"Creole\"', '$.cuisine');\n+-----------------------------------------------+\n| doc-&gt;&gt;\"$.name\"                                |\n+-----------------------------------------------+\n| Belvedere Restaurant                          |\n| Chez Macoule Restaurant                       |\n| Paradise Venus Restaurant                     |\n| Heavenly Fritaille Restaurant                 |\n| Yolie'S Bar &amp; Restaurant                      |\n| Yo-Yo Fritaille                               |\n| Kal Bakery &amp; Restaurant                       |\n| Bon Appetit Restaurant                        |\n| Katou Fin Restaurant                          |\n| Alhpa Restaurant                              |\n| Lakay Buffet Restaurant                       |\n| La Tranquilite Restaurant                     |\n| La Caye Restaurant                            |\n| Nous Les Amis Restaurant &amp; Bakery             |\n| Yoyo Fritaille                                |\n| Fresh Crown Restaurant                        |\n| Tonel Restaurant &amp; Lounge                     |\n| Grace Devine Pastry And Restaurant Restaurant |\n| Viva Bubble Tea                               |\n| Cafe Creole Restaurant N Bakery               |\n| Delly'S Place Restaurant &amp; Fritaille          |\n| Creole Plate                                  |\n| Chez Nous Restaurant &amp; Fritaille              |\n| Combite Creole                                |\n+-----------------------------------------------+<\/pre>\n<h3>JSON_CONTAINS_PATH<\/h3>\n<p>Indique si un document JSON contient des donn\u00e9es dans l&rsquo;un ou les chemins sp\u00e9cifi\u00e9s avec\u00a0<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json-search-functions.html#function_json-contains-path\" target=\"_blank\" rel=\"noopener noreferrer\">JSON_CONTAINS_PATH<\/a>.<\/p>\n<p>Pour tester cette fonction, j&rsquo;ins\u00e8re un document factice dans la collection restaurants :<\/p>\n<pre class=\"lang:mysql decode:true \" title=\"Insert a JSON document in the collection\">INSERT INTO restaurants (doc) VALUES ('{\"_id\": \"1234\", \"name\": \"Daz Restaurant\", \"cuisine\": \"West Indian\", \"restaurant_id\": \"4321\"}');<\/pre>\n<p>Combien y a t&rsquo;il de documents sans note (grades) ?<\/p>\n<pre class=\"lang:mysql decode:true \" title=\"Count number of documents without grades\">SELECT count(*), JSON_CONTAINS_PATH(doc, 'one', '$.grades') cp \nFROM restaurants \nGROUP BY cp;\n+----------+------+\n| count(*) | cp   |\n+----------+------+\n|        1 |    0 |\n|    25359 |    1 |\n+----------+------+<\/pre>\n<p>Un seul !\u00a0 Tu peux alors facilement v\u00e9rifier la structure de ce document :<\/p>\n<pre class=\"lang:mysql decode:true\" title=\"Document without grade \">SELECT JSON_PRETTY(doc) \nFROM restaurants \nWHERE JSON_CONTAINS_PATH(doc, 'one', '$.grades') = 0\\G\n*************************** 1. row ***************************\nJSON_PRETTY(doc): {\n  \"_id\": \"1234\",\n  \"name\": \"Daz Restaurant\",\n  \"cuisine\": \"West Indian\",\n  \"restaurant_id\": \"4321\"\n}<\/pre>\n<h2>Un pont entre ces deux mod\u00e8les<\/h2>\n<p>Pour paraphraser\u00a0<a href=\"https:\/\/twitter.com\/stoker\" target=\"_blank\" rel=\"noopener noreferrer\">David Stokes<\/a> (MySQL Community Manager) dans son livre\u00a0<a href=\"https:\/\/www.mhprofessional.com\/9781260135442-usa-mysql-and-json-a-practical-programming-guide-group\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>MySQL and JSON &#8211; A practical Programming Guide<\/strong><\/a>.<\/p>\n<p><em>\u00ab\u00a0<\/em><\/p>\n<p><em>The advantages of traditional relational data and schemaless data are both large. But in some cases, data in a schema needs to be schemaless, or schemaless-data needs to be in a schema.\u00a0<\/em><\/p>\n<p><em>\u00ab\u00a0<\/em><\/p>\n<p>Faire de tels transformations avec MySQL est extr\u00eamement ais\u00e9 !<\/p>\n<h3>Relationnel vers JSON<\/h3>\n<h4>JSON_OBJECT<\/h4>\n<p>\u00c9value une liste de paires cl\u00e9\/valeur et renvoie un objet JSON contenant ces paires avec\u00a0<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json-creation-functions.html#function_json-object\" target=\"_blank\" rel=\"noopener noreferrer\">JSON_OBJECT<\/a>.<\/p>\n<p>Une requ\u00eate SQL traditionnelle avec un jeu de r\u00e9sultats relationnel. En d&rsquo;autres termes, le document JSON g\u00e9n\u00e8re des donn\u00e9es non-JSON :<\/p>\n<pre class=\"lang:mysql decode:true\" title=\"Classical relational model\">SELECT doc-&gt;&gt;\"$.name\" \nFROM restaurants \nWHERE JSON_CONTAINS(doc, '\"Creole\"', '$.cuisine') \nLIMIT 2;\n+-------------------------+\n| doc-&gt;&gt;\"$.name\"          |\n+-------------------------+\n| Belvedere Restaurant    |\n| Chez Macoule Restaurant |\n+-------------------------+<\/pre>\n<p>Ce jeu de r\u00e9sultats peut \u00eatre converti au format JSON, plus pr\u00e9cis\u00e9ment en un objet JSON :<\/p>\n<pre class=\"lang:mysql decode:true \" title=\"Output in JSON format with JSON_OBJECT\">SELECT JSON_OBJECT(\"Name\", doc-&gt;&gt;\"$.name\") \nFROM restaurants \nWHERE JSON_CONTAINS(doc, '\"Creole\"', '$.cuisine') \nLIMIT 2;\n+-------------------------------------+\n| JSON_OBJECT(\"Name\", doc-&gt;&gt;\"$.name\") |\n+-------------------------------------+\n| {\"Name\": \"Belvedere Restaurant\"}    |\n| {\"Name\": \"Chez Macoule Restaurant\"} |\n+-------------------------------------+<\/pre>\n<p>Autre exemple :<\/p>\n<pre class=\"lang:mysql decode:true \" title=\"JSON_OBJECT\">SELECT Name, Population \nFROM City \nWHERE CountryCode='fra' \nORDER BY Population DESC \nLIMIT 5;\n+-----------+------------+\n| Name      | Population |\n+-----------+------------+\n| Paris     |    2125246 |\n| Marseille |     798430 |\n| Lyon      |     445452 |\n| Toulouse  |     390350 |\n| Nice      |     342738 |\n+-----------+------------+\n\n\nSELECT JSON_OBJECT(\"CityName\",Name, \"CityPop\", Population) \nFROM City \nWHERE CountryCode='fra' \nORDER BY Population DESC \nLIMIT 5;\n+-----------------------------------------------------+\n| JSON_OBJECT(\"CityName\",Name, \"CityPop\", Population) |\n+-----------------------------------------------------+\n| {\"CityPop\": 2125246, \"CityName\": \"Paris\"}           |\n| {\"CityPop\": 798430, \"CityName\": \"Marseille\"}        |\n| {\"CityPop\": 445452, \"CityName\": \"Lyon\"}             |\n| {\"CityPop\": 390350, \"CityName\": \"Toulouse\"}         |\n| {\"CityPop\": 342738, \"CityName\": \"Nice\"}             |\n+-----------------------------------------------------+<\/pre>\n<h4>JSON_OBJECTAGG<\/h4>\n<p>Prend deux noms de colonnes ou expressions et renvoie un objet JSON contenant des paires cl\u00e9\/valeur avec <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/group-by-functions.html#function_json-objectagg\" target=\"_blank\" rel=\"noopener noreferrer\">JSON_OBJECTAGG<\/a>.<\/p>\n<p>Agr\u00e9ger des colonnes est tr\u00e8s utile en SQL.<\/p>\n<pre class=\"lang:mysql decode:true \" title=\"JSON_OBJECTAGG\">SELECT JSON_OBJECTAGG(Name, CountryCode) \nFROM City  \nGROUP BY id \nORDER BY RAND() \nLIMIT 5;\n+-----------------------------------+\n| JSON_OBJECTAGG(Name, CountryCode) |\n+-----------------------------------+\n| {\"Reno\": \"USA\"}                   |\n| {\"Hanam\": \"KOR\"}                  |\n| {\"Laizhou\": \"CHN\"}                |\n| {\"Yogyakarta\": \"IDN\"}             |\n| {\"Tantoyuca\": \"MEX\"}              |\n+-----------------------------------+<\/pre>\n<ul>\n<li><em><span style=\"text-decoration: underline;\">Note<\/span>:\u00a0<\/em>\n<ul>\n<li><em>De mani\u00e8re g\u00e9n\u00e9rale, c&rsquo;est plut\u00f4t une <strong>tr\u00e8s mauvaise id\u00e9e<\/strong> d&rsquo;utiliser\u00a0ORDER BY RAND() pour g\u00e9n\u00e9rer des enregistrements al\u00e9atoires, car ce n&rsquo;est pas scalable (en clair, probl\u00e8mes de performance avec de grosses tables).<\/em><\/li>\n<li><em>Il vaut mieux g\u00e9rer l&rsquo;al\u00e9atoire au niveau de l&rsquo;application ou alors pr\u00e9-calculer les valeurs al\u00e9atoires et les stocker dans la base<\/em>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>JSON_ARRAY<\/h4>\n<p>Evalue une liste de valeurs et retourne un tableau JSON contenant ces valeurs avec\u00a0<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json-creation-functions.html#function_json-array\" target=\"_blank\" rel=\"noopener noreferrer\">JSON_ARRAY<\/a>.<\/p>\n<p>L&rsquo;exemple qui suit est une requ\u00eate\u00a0<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/with.html\" target=\"_blank\" rel=\"noopener noreferrer\">Common Table Expression<\/a>\u00a0r\u00e9cursive aka recursive CTE (ou encore requ\u00eate WITH) qui permet de parcourir une hi\u00e9rarchie sans connaitre sa profondeur :<\/p>\n<pre class=\"lang:mysql decode:true \" title=\"Hierarchical Query using a Recursive CTE\">WITH RECURSIVE emp_ext (id, name, path) AS ( \n    SELECT id, name, CAST(id AS CHAR(200)) \n    FROM employees \n    WHERE manager_id IS NULL \n    UNION ALL \n    SELECT s.id, s.name, CONCAT(m.path, \",\", s.id) \n    FROM emp_ext m \n        JOIN employees s ON m.id=s.manager_id \n) \nSELECT id,name, path FROM emp_ext ORDER BY path;\n+------+---------+-----------------+\n| id   | name    | path            |\n+------+---------+-----------------+\n|  333 | Yasmina | 333             |\n|  198 | John    | 333,198         |\n|   29 | Pedro   | 333,198,29      |\n| 4610 | Sarah   | 333,198,29,4610 |\n|   72 | Pierre  | 333,198,29,72   |\n|  692 | Tarek   | 333,692         |\n|  123 | Adil    | 333,692,123     |\n+------+---------+-----------------+<\/pre>\n<p>G\u00e9n\u00e9rer du JSON avec JSON_OBJECT &amp; JSON_ARRAY :<\/p>\n<pre class=\"lang:mysql decode:true\" title=\"Hierarchical Query using a Recursive CTE JSON format output\">WITH RECURSIVE emp_ext (id, name, path) AS ( \n    SELECT id, name, CAST(id AS CHAR(200)) \n    FROM employees \n    WHERE manager_id IS NULL \n    UNION ALL \n    SELECT s.id, s.name, CONCAT(m.path, \",\", s.id) \n    FROM emp_ext m \n        JOIN employees s ON m.id=s.manager_id \n) \nSELECT JSON_OBJECT(\"ID\",id, \"Name\",name, \"Path\", JSON_ARRAY(path)) \nFROM emp_ext \nORDER BY path;\n+-------------------------------------------------------------+\n| JSON_OBJECT(\"ID\",id, \"Name\",name, \"Path\", JSON_ARRAY(path)) |\n+-------------------------------------------------------------+\n| {\"ID\": 333, \"Name\": \"Yasmina\", \"Path\": [\"333\"]}             |\n| {\"ID\": 198, \"Name\": \"John\", \"Path\": [\"333,198\"]}            |\n| {\"ID\": 29, \"Name\": \"Pedro\", \"Path\": [\"333,198,29\"]}         |\n| {\"ID\": 4610, \"Name\": \"Sarah\", \"Path\": [\"333,198,29,4610\"]}  |\n| {\"ID\": 72, \"Name\": \"Pierre\", \"Path\": [\"333,198,29,72\"]}     |\n| {\"ID\": 692, \"Name\": \"Tarek\", \"Path\": [\"333,692\"]}           |\n| {\"ID\": 123, \"Name\": \"Adil\", \"Path\": [\"333,692,123\"]}        |\n+-------------------------------------------------------------+<\/pre>\n<h4>JSON_ARRAYAGG<\/h4>\n<p>Agr\u00e9ger un ensemble de r\u00e9sultats en un seul tableau JSON dont les \u00e9l\u00e9ments sont constitu\u00e9s des lignes avec\u00a0<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/group-by-functions.html#function_json-arrayagg\" target=\"_blank\" rel=\"noopener noreferrer\">JSON_ARRAYAGG<\/a>.<\/p>\n<p>A l&rsquo;aide de cette autre fonction JSON d&rsquo;agr\u00e9gation voici diff\u00e9rentes requ\u00eates SQL qui g\u00e9n\u00e8rent du JSON :<\/p>\n<pre class=\"lang:mysql decode:true \" title=\"JSON_ARRAYAGG\">SELECT CountryCode, JSON_ARRAYAGG(City.Name) \nFROM City \n    JOIN Country ON (City.CountryCode=Country.Code) \nWHERE Continent='Europe' \nGROUP BY 1 \nLIMIT 5;\n+-------------+--------------------------------------------------------------------------------------------------------------+\n| CountryCode | JSON_ARRAYAGG(City.Name)                                                                                     |\n+-------------+--------------------------------------------------------------------------------------------------------------+\n| ALB         | [\"Tirana\"]                                                                                                   |\n| AND         | [\"Andorra la Vella\"]                                                                                         |\n| AUT         | [\"Graz\", \"Linz\", \"Salzburg\", \"Innsbruck\", \"Wien\", \"Klagenfurt\"]                                              |\n| BEL         | [\"Antwerpen\", \"Brugge\", \"Gent\", \"Schaerbeek\", \"Charleroi\", \"Namur\", \"Li\u00e8ge\", \"Mons\", \"Bruxelles [Brussel]\"]  |\n| BGR         | [\"\u0160umen\", \"Sofija\", \"Stara Zagora\", \"Plovdiv\", \"Pleven\", \"Varna\", \"Sliven\", \"Burgas\", \"Dobric\", \"Ruse\"]      |\n+-------------+--------------------------------------------------------------------------------------------------------------+<\/pre>\n<pre class=\"lang:mysql decode:true \" title=\"JSON_OBJECT &amp; JSON_ARRAYAGG\">SELECT JSON_OBJECT(\"CountryCode\",CountryCode), JSON_OBJECT(\"CityName\",JSON_ARRAYAGG(City.Name)) \nFROM City \n    JOIN Country ON (City.CountryCode=Country.Code) \nWHERE Continent='Europe' \nGROUP BY 1 \nLIMIT 5;\n+----------------------------------------+----------------------------------------------------------------------------------------------------------------------------+\n| JSON_OBJECT(\"CountryCode\",CountryCode) | JSON_OBJECT(\"CityName\",JSON_ARRAYAGG(City.Name))                                                                           |\n+----------------------------------------+----------------------------------------------------------------------------------------------------------------------------+\n| {\"CountryCode\": \"ALB\"}                 | {\"CityName\": [\"Tirana\"]}                                                                                                   |\n| {\"CountryCode\": \"AND\"}                 | {\"CityName\": [\"Andorra la Vella\"]}                                                                                         |\n| {\"CountryCode\": \"AUT\"}                 | {\"CityName\": [\"Wien\", \"Graz\", \"Linz\", \"Salzburg\", \"Innsbruck\", \"Klagenfurt\"]}                                              |\n| {\"CountryCode\": \"BEL\"}                 | {\"CityName\": [\"Schaerbeek\", \"Mons\", \"Namur\", \"Brugge\", \"Li\u00e8ge\", \"Antwerpen\", \"Charleroi\", \"Gent\", \"Bruxelles [Brussel]\"]}  |\n| {\"CountryCode\": \"BGR\"}                 | {\"CityName\": [\"Burgas\", \"\u0160umen\", \"Dobric\", \"Sliven\", \"Pleven\", \"Stara Zagora\", \"Ruse\", \"Varna\", \"Plovdiv\", \"Sofija\"]}      |\n+----------------------------------------+----------------------------------------------------------------------------------------------------------------------------+<\/pre>\n<pre class=\"lang:mysql decode:true \" title=\"JSON_OBJECT &amp; JSON_OBJECT\">SELECT JSON_OBJECT(\"Code\",CountryCode, \"CityName\", JSON_ARRAYAGG(City.Name)) \nFROM City \n    JOIN Country ON (City.CountryCode=Country.Code) \nWHERE Continent='Europe' \nGROUP BY CountryCode \nLIMIT 5;\n+-------------------------------------------------------------------------------------------------------------------------------------------+\n| JSON_OBJECT(\"Code\",CountryCode, \"CityName\", JSON_ARRAYAGG(City.Name))                                                                     |\n+-------------------------------------------------------------------------------------------------------------------------------------------+\n| {\"Code\": \"ALB\", \"CityName\": [\"Tirana\"]}                                                                                                   |\n| {\"Code\": \"AND\", \"CityName\": [\"Andorra la Vella\"]}                                                                                         |\n| {\"Code\": \"AUT\", \"CityName\": [\"Graz\", \"Linz\", \"Salzburg\", \"Innsbruck\", \"Wien\", \"Klagenfurt\"]}                                              |\n| {\"Code\": \"BEL\", \"CityName\": [\"Bruxelles [Brussel]\", \"Antwerpen\", \"Brugge\", \"Gent\", \"Schaerbeek\", \"Charleroi\", \"Namur\", \"Li\u00e8ge\", \"Mons\"]}  |\n| {\"Code\": \"BGR\", \"CityName\": [\"Ruse\", \"\u0160umen\", \"Sofija\", \"Stara Zagora\", \"Plovdiv\", \"Pleven\", \"Varna\", \"Sliven\", \"Burgas\", \"Dobric\"]}      |\n+-------------------------------------------------------------------------------------------------------------------------------------------+<\/pre>\n<h3>JSON vers Relationnel<\/h3>\n<p>Maintenant le processus inverse. Transformation des donn\u00e9es JSON en donn\u00e9es relationnelles.<\/p>\n<h4>JSON_TABLE<\/h4>\n<p>Extrait les donn\u00e9es d&rsquo;un document JSON et renvoies-les en tant que table relationnelle avec <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json-table-functions.html#function_json-table\" target=\"_blank\" rel=\"noopener noreferrer\">JSON_TABLE<\/a>.<\/p>\n<p>Conseil amical, je te recommande fortement de passer du temps dans la documentation de cette puissante et compl\u00e8te fonction, qui va te permettre de mapper des donn\u00e9es JSON dans une table relationnelle temporaire, puis d&rsquo;interroger cette derni\u00e8re.<\/p>\n<p>Assez de blabla, voici quelques exemples :<\/p>\n<pre class=\"lang:mysql decode:true\" title=\"JSON_TABLE\">SELECT GNP \nFROM countryinfo, JSON_TABLE(doc, \"$\" COLUMNS (GNP int PATH \"$.GNP\")) AS jst \nWHERE _id='FRA';\n+---------+\n| GNP     |\n+---------+\n| 1424285 |\n+---------+<\/pre>\n<pre class=\"lang:mysql decode:true\" title=\"JSON_TABLE\">SELECT GNP, Name, LifeExpectancy \nFROM countryinfo, JSON_TABLE(doc, \"$\" COLUMNS (GNP int PATH \"$.GNP\", Name char(255) PATH \"$.Name\", LifeExpectancy int PATH \"$.demographics.LifeExpectancy\")) AS jst \nWHERE _id IN ('FRA', 'USA');\n+---------+---------------+----------------+\n| GNP     | Name          | LifeExpectancy |\n+---------+---------------+----------------+\n| 1424285 | France        |             79 |\n| 8510700 | United States |             77 |\n+---------+---------------+----------------+<\/pre>\n<pre class=\"lang:mysql decode:true \" title=\"JSON_TABLE\">SELECT name AS \"Creole Cuisine\" \nFROM restaurant.restaurants, JSON_TABLE(doc, \"$\" COLUMNS (name char(100) PATH \"$.name\", cuisine char(100) PATH \"$.cuisine\")) AS jst \nWHERE cuisine='Creole';\n+-----------------------------------------------+\n| Creole Cuisine                                |\n+-----------------------------------------------+\n| Belvedere Restaurant                          |\n| Chez Macoule Restaurant                       |\n| Paradise Venus Restaurant                     |\n| Heavenly Fritaille Restaurant                 |\n| Yolie'S Bar &amp; Restaurant                      |\n| Yo-Yo Fritaille                               |\n| Kal Bakery &amp; Restaurant                       |\n| Bon Appetit Restaurant                        |\n| Katou Fin Restaurant                          |\n| Alhpa Restaurant                              |\n| Lakay Buffet Restaurant                       |\n| La Tranquilite Restaurant                     |\n| La Caye Restaurant                            |\n| Nous Les Amis Restaurant &amp; Bakery             |\n| Yoyo Fritaille                                |\n| Fresh Crown Restaurant                        |\n| Tonel Restaurant &amp; Lounge                     |\n| Grace Devine Pastry And Restaurant Restaurant |\n| Viva Bubble Tea                               |\n| Cafe Creole Restaurant N Bakery               |\n| Delly'S Place Restaurant &amp; Fritaille          |\n| Creole Plate                                  |\n| Chez Nous Restaurant &amp; Fritaille              |\n| Combite Creole                                |\n+-----------------------------------------------+<\/pre>\n<h4>JSON_TABLE &#8211; Nested Data<\/h4>\n<p>Parcours le chemin du document JSON et r\u00e9cup\u00e8re les donn\u00e9es imbriqu\u00e9es.<\/p>\n<p>Par exemple, extraire toutes les notes (grades) des restaurants qui font de la cuisine Hawaiian :<\/p>\n<pre class=\"lang:mysql decode:true\" title=\"JSON_TABLE - Nested data\">SELECT name, cuisine, gradeID, grade \nFROM restaurants,JSON_TABLE(doc, \"$\" COLUMNS (name char(100) PATH \"$.name\", cuisine char(100) PATH \"$.cuisine\", NESTED PATH \"$.grades[*]\" COLUMNS (gradeID FOR ORDINALITY, grade char(20) PATH \"$.grade\"))) AS jst \nWHERE cuisine='Hawaiian';\n+------------------+----------+---------+-------+\n| name             | cuisine  | gradeID | grade |\n+------------------+----------+---------+-------+\n| Makana           | Hawaiian |       1 | C     |\n| Makana           | Hawaiian |       2 | C     |\n| Makana           | Hawaiian |       3 | A     |\n| Makana           | Hawaiian |       4 | C     |\n| Makana           | Hawaiian |       5 | A     |\n| General Assembly | Hawaiian |       1 | A     |\n| General Assembly | Hawaiian |       2 | A     |\n| General Assembly | Hawaiian |       3 | A     |\n| General Assembly | Hawaiian |       4 | A     |\n| Onomea           | Hawaiian |       1 | A     |\n| Onomea           | Hawaiian |       2 | A     |\n+------------------+----------+---------+-------+<\/pre>\n<h4>JSON_TABLE &#8211; Missing Data<\/h4>\n<p>Pr\u00e9cise quelle action \u00e0 accomplir en cas de donn\u00e9es manquantes.<\/p>\n<p>Comportement par d\u00e9faut :<\/p>\n<pre class=\"lang:mysql decode:true \" title=\"JSON_TABLE - Missing Data\">SELECT name, cuisine, borough \nFROM restaurant.restaurants,JSON_TABLE(doc, \"$\" COLUMNS (name char(100) PATH \"$.name\", cuisine char(100) PATH \"$.cuisine\", borough char(100) PATH \"$.borough\")) AS jst  \nLIMIT 2;\n+--------------------------------+-------------+-----------+\n| name                           | cuisine     | borough   |\n+--------------------------------+-------------+-----------+\n| Daz Restaurant                 | West Indian | NULL      |\n| Dj Reynolds Pub And Restaurant | Irish       | Manhattan |\n+--------------------------------+-------------+-----------+<\/pre>\n<p>Renforce le comportement par d\u00e9faut :<\/p>\n<pre class=\"lang:mysql decode:true \" title=\"JSON_TABLE - Missing Data\">SELECT name, cuisine, borough \nFROM restaurant.restaurants,JSON_TABLE(doc, \"$\" COLUMNS (name char(100) PATH \"$.name\", cuisine char(100) PATH \"$.cuisine\", borough char(100) PATH \"$.borough\" NULL ON EMPTY)) AS jst \nLIMIT 2;\n+--------------------------------+-------------+-----------+\n| name                           | cuisine     | borough   |\n+--------------------------------+-------------+-----------+\n| Daz Restaurant                 | West Indian | NULL      |\n| Dj Reynolds Pub And Restaurant | Irish       | Manhattan |\n+--------------------------------+-------------+-----------+<\/pre>\n<p>D\u00e9clenche une erreur :<\/p>\n<pre class=\"lang:mysql decode:true \" title=\"JSON_TABLE - Missing Data\">SELECT name, cuisine, borough \nFROM restaurant.restaurants,JSON_TABLE(doc, \"$\" COLUMNS (name char(100) PATH \"$.name\", cuisine char(100) PATH \"$.cuisine\", borough char(100) PATH \"$.borough\" ERROR ON EMPTY)) AS jst \nLIMIT 2;\nERROR 3665 (22035): Missing value for JSON_TABLE column 'borough'<\/pre>\n<p>Mettre une valeur par d\u00e9faut :<\/p>\n<pre class=\"lang:mysql decode:true \" title=\"JSON_TABLE - Missing Data\">SELECT name, cuisine, borough \nFROM restaurant.restaurants,JSON_TABLE(doc, \"$\" COLUMNS (name char(100) PATH \"$.name\", cuisine char(100) PATH \"$.cuisine\", borough char(100) PATH \"$.borough\" DEFAULT '\"&lt;UNKNOW&gt;\"' ON EMPTY)) AS jst \nLIMIT 2;\n+--------------------------------+-------------+-----------+\n| name                           | cuisine     | borough   |\n+--------------------------------+-------------+-----------+\n| Daz Restaurant                 | West Indian | &lt;UNKNOW&gt;  |\n| Dj Reynolds Pub And Restaurant | Irish       | Manhattan |\n+--------------------------------+-------------+-----------+<\/pre>\n<h2>Le(s) mot(s) de la fin<\/h2>\n<p>MySQL 8 et 5.7 poss\u00e8dent un riche jeu de fonctions JSON. J&rsquo;en ai pr\u00e9sent\u00e9 quelques unes mais rassures toi il t&rsquo;en reste encore pas mal \u00e0 d\u00e9couvrir, notamment pour cr\u00e9er, modifier,indexer&#8230; les documents.<\/p>\n<p>A noter \u00e9galement que si le mod\u00e8le relationnel ne convient pas \u00e0 ton\u00a0workload, <a href=\"https:\/\/mysqlserverteam.com\/mysql-8-0-announcing-ga-of-the-mysql-document-store\/\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"text-decoration: underline;\"><strong>MySQL 8 Document Store<\/strong><\/span><\/a> t&rsquo;offre la possibilit\u00e9 de g\u00e9rer tes collections \u00e0 l&rsquo;aide d&rsquo;une API CRUD NoSQL. J&rsquo;en parlerai plus en d\u00e9tail dans un prochain article.<\/p>\n<p>Pour patienter je t&rsquo;invite \u00e0 lire\u00a0:\u00a0<a href=\"https:\/\/lefred.be\/content\/top-10-reasons-for-nosql-with-mysql\/\" target=\"_blank\" rel=\"noopener noreferrer\">Top 10 reasons for NoSQL with MySQL<\/a>.<\/p>\n<h2>Pour aller plus loin<\/h2>\n<p><span style=\"text-decoration: underline;\">Documentation<\/span><\/p>\n<ul>\n<li><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/json-function-reference.html\" target=\"_blank\" rel=\"noopener noreferrer\">JSON Functions Reference<\/a><\/li>\n<li><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/group-by-functions.html#function_json-objectagg\" target=\"_blank\" rel=\"noopener noreferrer\">Aggregate (GROUP BY) Function Descriptions<\/a><\/li>\n<\/ul>\n<p><span style=\"text-decoration: underline;\">Articles<\/span><\/p>\n<ul>\n<li><a href=\"http:\/\/dasini.net\/blog\/2015\/11\/17\/30-mins-avec-json-en-mysql\/\" target=\"_blank\" rel=\"noopener noreferrer\">30 mins avec JSON en MySQL<\/a><\/li>\n<li><a href=\"http:\/\/dasini.net\/blog\/2015\/11\/30\/json-et-colonnes-generees-avec-mysql\/\" target=\"_blank\" rel=\"noopener noreferrer\">JSON et colonnes g\u00e9n\u00e9r\u00e9es avec MySQL<\/a><\/li>\n<li><a href=\"https:\/\/mysqlserverteam.com\/new-json-functions-in-mysql-5-7-22\/\" target=\"_blank\" rel=\"noopener noreferrer\">New JSON functions in MySQL 5.7.22<\/a><\/li>\n<li><a href=\"https:\/\/mysqlserverteam.com\/mysql-8-0-from-sql-tables-to-json-documents-and-back-again\/\" target=\"_blank\" rel=\"noopener noreferrer\">MySQL 8.0: From SQL Tables to JSON Documents (and back again)<\/a><\/li>\n<\/ul>\n<p><span style=\"text-decoration: underline;\">Autres ressources<\/span><\/p>\n<ul>\n<li>Tu trouveras les bases de donn\u00e9es utilis\u00e9es dans cet article <a href=\"https:\/\/dev.mysql.com\/doc\/index-other.html\" target=\"_blank\" rel=\"noopener noreferrer\">ici<\/a>.<\/li>\n<li>Le dump de la collection\u00a0Restaurants\u00a0<a href=\"https:\/\/github.com\/freshdaz\/MySQL-dump-of-restaurants-table\" target=\"_blank\" rel=\"noopener noreferrer\">ici<\/a>.<\/li>\n<li>Quelques livres qui peuvent \u00eatre utile : <a href=\"http:\/\/dasini.net\/blog\/2018\/07\/12\/plenty-of-new-mysql-books\/\" target=\"_blank\" rel=\"noopener noreferrer\">ici<\/a>.<\/li>\n<\/ul>\n<p>Thanks for using MySQL!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Comme tu le sais,\u00a0JSON (JavaScript Object Notation) est un populaire format d&rsquo;\u00e9change de donn\u00e9es. Depuis la version 5.7, MySQL supporte un type de donn\u00e9es JSON\u00a0natif (au format interne binaire pour des raisons d&rsquo;efficacit\u00e9s), ainsi qu&rsquo;un riche ensemble de fonctions qui te permettront de manipuler dans tout les sens tes documents JSON.<br \/>\nSoyons clair! Cet article n&rsquo;est pas une revue exhaustive des diff\u00e9rentes fonctions JSON impl\u00e9ment\u00e9es dans MySQL (RTFM! c&rsquo;est mieux), mais plut\u00f4t une s\u00e9lection arbitraire de certaines d&rsquo;entre elles.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"categories":[260,8,284],"tags":[427,278,276],"class_list":["post-2492","post","type-post","status-publish","format-standard","hentry","category-json-fr","category-mysql","category-nosql","tag-cte-fr","tag-json","tag-nosql"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9LfWW-Ec","jetpack-related-posts":[{"id":1533,"url":"https:\/\/dasini.net\/blog\/2015\/11\/17\/30-mins-avec-json-en-mysql\/","url_meta":{"origin":2492,"position":0},"title":"30 mins avec JSON en MySQL","author":"Olivier DASINI","date":"17 novembre 2015","format":false,"excerpt":"Comme vous le savez MySQL 5.7 est GA. Cette nouvelle mouture de la base de donn\u00e9es open source la plus populaire au monde a plus de 150 nouvelles fonctionnalit\u00e9s. L'une d'entre elle est un type de donn\u00e9es JSON natif ainsi que les fonctions JSON associ\u00e9es. Prenons 30 minutes pour voir\u2026","rel":"","context":"Dans &quot;json&quot;","block_context":{"text":"json","link":"https:\/\/dasini.net\/blog\/category\/json-fr\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1634,"url":"https:\/\/dasini.net\/blog\/2016\/08\/29\/meetup-mysql-group-replication-mysql-as-a-document-store\/","url_meta":{"origin":2492,"position":1},"title":"Meetup &#8211; MySQL Group Replication &#038; MySQL as a Document Store","author":"Olivier DASINI","date":"29 ao\u00fbt 2016","format":false,"excerpt":"Oracle MySQL, Openska et Executive MBA Epitech ont le plaisir de vous inviter le mardi 6 septembre pour le premier meetup MySQL de la rentr\u00e9e. Au programme: MySQL Group Replication & MySQL as a Document Store","rel":"","context":"Dans &quot;Conf\u00e9rence&quot;","block_context":{"text":"Conf\u00e9rence","link":"https:\/\/dasini.net\/blog\/category\/conference\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mysqlhighavailability.com\/wp-content\/uploads\/2014\/09\/1.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2450,"url":"https:\/\/dasini.net\/blog\/2018\/07\/12\/nouveaux-livres-mysql\/","url_meta":{"origin":2492,"position":2},"title":"Nouveaux livres MySQL","author":"Olivier DASINI","date":"12 juillet 2018","format":false,"excerpt":"Jadis, lorsque l'on voulait approfondir un sujet technique, il nous fallait \u00e0 tout prix LE livre (celui l\u00e0\u00a0\u00e0 litt\u00e9ralement chang\u00e9 ma vie, et ce n'est pas le seul: celui l\u00e0, celui l\u00e0,...). De nos jours, des milliards de ressources sont disponibles gratuitement sur internet, mais il faut bien l'avouer, la\u2026","rel":"","context":"Dans &quot;Divers&quot;","block_context":{"text":"Divers","link":"https:\/\/dasini.net\/blog\/category\/divers\/"},"img":{"alt_text":"MySQL and JSON: A Practical Programming Guide - Discover how to use JavaScript Object Notation (JSON) with MySQL","src":"https:\/\/i0.wp.com\/images-na.ssl-images-amazon.com\/images\/I\/416UKa-bH%2BL._SX332_BO1%2C204%2C203%2C200_.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1620,"url":"https:\/\/dasini.net\/blog\/2016\/04\/21\/mysql-en-tant-que-document-store\/","url_meta":{"origin":2492,"position":3},"title":"MySQL en tant que Document Store","author":"Olivier DASINI","date":"21 avril 2016","format":false,"excerpt":"A partir de MySQL 5.7.12, la nouvelle version de la base de donn\u00e9es la plus populaire, Les devs and DBAs peuvent maintenant d\u00e9ployer des bases MySQL qui impl\u00e9mentent un mod\u00e8le document store, relationnel ou hybride (document ET relationnel) ! Plus d'info: http:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/document-store.ht","rel":"","context":"Dans &quot;MySQL&quot;","block_context":{"text":"MySQL","link":"https:\/\/dasini.net\/blog\/category\/mysql\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2715,"url":"https:\/\/dasini.net\/blog\/2018\/11\/07\/mysql-day-paris-nosql-sql-mysql\/","url_meta":{"origin":2492,"position":4},"title":"MySQL Day Paris &#8211; NoSQL + SQL = MySQL","author":"Olivier DASINI","date":"7 novembre 2018","format":false,"excerpt":"\u00c9quation simple, quoique un tantinet intrigante, n'est ce pas ? En fait, MySQL 8.0 permet l'unification des donn\u00e9es non structur\u00e9es (schema-less) et des donn\u00e9es structur\u00e9es (schema-based) dans une seule et m\u00eame pile technologique !!! MySQL 8.0 c'est aussi pl\u00e9thore de nouvelles fonctionnalit\u00e9s li\u00e9es \u00e0 la s\u00e9curit\u00e9, \u00e0 la haute disponibilit\u00e9,\u2026","rel":"","context":"Dans &quot;Conf\u00e9rence&quot;","block_context":{"text":"Conf\u00e9rence","link":"https:\/\/dasini.net\/blog\/category\/conference\/"},"img":{"alt_text":"Oracle MySQL Day Paris","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/MySQL_Day_Paris6.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2959,"url":"https:\/\/dasini.net\/blog\/2019\/04\/08\/200\/","url_meta":{"origin":2492,"position":5},"title":"200 !!","author":"Olivier DASINI","date":"8 avril 2019","format":false,"excerpt":"Cet article est en fait mon 200 \u00e8me \\o\/ Pour marquer le coup, j'ai d\u00e9cid\u00e9 de faire une petite pause et de regarder dans le r\u00e9troviseur...","rel":"","context":"Dans &quot;Divers&quot;","block_context":{"text":"Divers","link":"https:\/\/dasini.net\/blog\/category\/divers\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/2492","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/comments?post=2492"}],"version-history":[{"count":25,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/2492\/revisions"}],"predecessor-version":[{"id":5872,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/2492\/revisions\/5872"}],"wp:attachment":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/media?parent=2492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/categories?post=2492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/tags?post=2492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}