Working With JSON in MySQL - Scotch
Working With JSON in MySQL - Scotch
io)
Topshelfwebdevelopertraining.
About(https://scotch.io/about) Login/Register
Menu
scotch
(https://scotch.io)
Subscribe & get our FREE eBook
Build Your First Node.js App
Email Address
Stalk Us
(https://twitter.com/scotch_io)
laravel(https://scotch.io/tag/laravel) php(https://scotch.io/tag/php)
Working with JSON in (https://www.facebook.com/scotchdeve
MySQL
(https://github.com/scotch-io)
LearnhowtouseandqueryJSONdatainyour
MYSQLdatabases.
(https://feeds.feedblitz.com/scotch_io)
(https://pub.scotch.io/@nomanurrehman)
12,461
RELATEDCOURSE
Get Started
)
(https://bit.ly/2koLun3)
ps
hi
ps
rs
hi
so
rs
on
so
sp
on
e/
Sp
yp
/t
.io
ch
ot
sc
//
s:
)
ps
hi
ps
rs
hi
so
rs
on
so
sp
on
e/
Sp
yp
SQLdatabasestendtoberigid.
/t
io
h.
tc
co
/s
:/
ps
tt
(h
Ifyouhaveworkedwiththem,youwouldagreethatdatabase
designthoughitseemseasier,isalottrickierinpractice.SQL
databasesbelieveinstructure,thatiswhyit'scalledstructured
querylanguage.
Ontheothersideofthehorizon,wehavetheNoSQLdatabases,
alsocalledschema-lessdatabasesthatencourageflexibility.In
schema-lessdatabases,thereisnoimposedstructuralrestriction,
Best Courses
onlydatatobesaved.
Thougheverytoolhasit'susecase,sometimesthingscallfora
hybridapproach.
Whatifyoucouldstructuresomepartsofyourdatabaseandleave
otherstobeflexible?
MySQLversion5.7.8
(https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-
8.html)introducesaJSONdatatypethatallowsyoutoaccomplish
that.
Inthistutorial,youaregoingtolearn.
1.HowtodesignyourdatabasetablesusingJSONfields.
2.ThevariousJSONbasedfunctionsavailableinMYSQLto ()
create,read,update,anddeleterows.
3.HowtoworkwithJSONfieldsusingtheEloquentORMin
Laravel.
Letmeexplainwithanexample.
Supposeyouarebuildingawebapplicationwhereyouhavetosave
auser'sconfiguration/preferencesinthedatabase.
Generally,youcancreateaseparatedatabasetablewiththe id ,
user_id , key ,and value fieldsorsaveitasaformattedstringthat
youcanparseatruntime.
However,thisworkswellforasmallnumberofusers.Ifyouhave
aboutathousandusersandfiveconfigurationkeys,youare
lookingatatablewithfivethousandrecordsthataddressesavery
smallfeatureofyourapplication.
Orifyouaretakingtheformattedstringroute,extraneouscode
thatonlycompoundsyourserverload.
UsingaJSONdatatypefieldtosaveauser'sconfigurationinsucha
scenariocanspareyouadatabasetable'sspaceandbringdown
thenumberofrecords,whichwerebeingsavedseparately,tobe
thesameasthenumberofusers.
AndyougettheaddedbenefitofnothavingtowriteanyJSON
parsingcode,theORMorthelanguageruntimetakescareofit.
# The Schema
BeforewediveintousingallthecoolJSONstuffinMySQL,weare
goingtoneedasampledatabasetoplaywith.
So,let'sgetourdatabaseschemaoutofthewayfirst.
Wearegoingtoconsidertheusecaseofanonlinestorethat
housesmultiplebrandsandavarietyofelectronics.
Sincedifferentelectronicshavedifferentattributes(comparea
MacbookwithaVacuumnCleaner)thatbuyersareinterestedin, (https://hrd.cm/2k90ljr)
HIRED
typicallytheEntityattributevaluemodel(EAV)
(https://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model)
(https://hrd.cm/2k90ljr) Hired is the absolute best way to nd a tech or
design job.
patternisused.
(https://twitter.com/intent/tweet?url=https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fscotch.io%2Ftutorials%2Fworking-with-json-in- Get Hired.
mysql&text=Working+with+JSON+in+MySQL&via=scotch_io&related=scotch_io)
However,sincewenowhavetheoptiontouseaJSONdatatype,we
Subscribe & get our FREE eBook
aregoingtodropEAV.
Build Your First Node.js App
Forastart,ourdatabasewillbenamed e_store andhasthree
Email Address
tablesonlynamed, brands , categories ,and products respectively.
Free Node Book
SQL
Theobjectiveofthesetwotableswillbetohousetheproduct
categoriesandthebrandsthatprovidetheseproducts.
Whileweareatit,letusgoaheadandseedsomedataintothese
tablestouselater.
FIND YOUR
OPPORTUNITY
HIRED
(https://hrd.cm/2k90ljr)
SQL
/* Brands */
INSERT INTO `e_store`.`brands`(`name`)
VALUES
('Samsung');
Next,isthebusinessareaofthistutorial.
(https://hrd.cm/2k90ljr)
SQL
Ourtabledefinitionspecifiesforeignkeyconstraintsforthe
brand_id and category_id fields,specifyingthattheyreferencethe
brands and categories tablerespectively.Wehavealsospecifiedthat
thereferencedrowsshouldnotbeallowedtodeleteandif
updated,thechangesshouldreflectinthereferencesaswell.
Hereisanentityrelationshipdiagramofourcreateddatabase.
(https://hrd.cm/2k90ljr)
Ourdatabasedesignisnotthebest
intermsofefficiencyandaccuracy.
Thereisnopricecolumninthe
products tableandwecoulddowith
puttingaproductintomultiple
categories.However,thepurposeof
thistutorialisnottoteachdatabase
designbutratherhowtomodel
objectsofdifferentnatureinasingle
tableusingMySQL'sJSONfeatures.
(https://hrd.cm/2k90ljr)
# The CRUD Operations
Letuslookathowtocreate,read,update,anddeletedataina
JSONfield.
CREATE
CreatingarecordinthedatabasewithaJSONfieldisprettysimple.
AllyouneedtodoisaddvalidJSONasthefieldvalueinyourinsert
statement.
(https://hrd.cm/2k90ljr)
SQL
(https://hrd.cm/2k90ljr)
INSERT INTO `e_store`.`products`(
`name` ,
`brand_id` ,
`category_id` ,
`attributes`
)
VALUES(
'Bravia' ,
'1' ,
'1' ,
'{"screen": "25 inch", "resolution": "1366 x 768 pixels", "ports": {"hdmi": 1, "usb": 0}, "speakers": {"left": "5
);
InsteadoflayingouttheJSONobjectyourself,youcanalsousethe
built-in JSON_OBJECT function.
(https://hrd.cm/2k90ljr)
SQL
Ifyouspecifyasinglekeymultipletimes,onlythefirstkey/value
pairwillberetained.ThisiscallednormalizingtheJSONinMySQL's
terms.Also,aspartofnormalization,theobjectkeysaresortedand
theextrawhite-spacebetweenkey/valuepairsisremoved.
AnotherfunctionthatwecanusetocreateJSONobjectsisthe
JSON_MERGE function.
(https://hrd.cm/2k90ljr)
SQL
Thereisalothappeningintheseinsertstatementsanditcangeta
bitconfusing.However,itisprettysimple.
AproofofconceptisinorderIsuppose.
SQL
Wecanconfirmallourquerieswererunsuccessfullyusingthe
JSON_TYPE functionwhichgivesusthefieldvaluetype.
(https://hrd.cm/2k90ljr)
SQL
/* output: OBJECT */
SELECT JSON_TYPE(attributes) FROM `e_store`.`products`;
READ
Right,wehaveafewproductsinourdatabasetoworkwith.
FortypicalMySQLvaluesthatarenotoftypeJSON,awhereclause
isprettystraight-forward.Justspecifythecolumn,anoperator,and
thevaluesyouneedtoworkwith.
Heuristically,whenworkingwithJSONcolumns,thisdoesnotwork.
SQL
WhenyouwishtonarrowdownrowsusingaJSONfield,youshould
befamiliarwiththeconceptofapathexpression.
(https://hrd.cm/2k90ljr)
Themostsimplestdefinitionofapathexpression(thinkJQuery
selectors)isit'susedtospecifywhichpartsoftheJSONdocument
toworkwith.
Thesecondpieceofthepuzzleisthe JSON_EXTRACT functionwhich
acceptsapathexpressiontonavigatethroughJSON.
Letussayweareinterestedintherangeoftelevisionsthathave
atleastasingleUSBandHDMIport.
SQL
SELECT
*
FROM
`e_store`.`products`
WHERE
`category_id` = 1
AND JSON_EXTRACT(`attributes` , '$.ports.usb') > 0
AND JSON_EXTRACT(`attributes` , '$.ports.hdmi') > 0;
Oncewehaveextractedthekeysweareinterestedin,itispretty
simpletousetheMySQLoperatorssuchas > onthem.
Revisingourpreviousquery.
(https://hrd.cm/2k90ljr)
SQL
SELECT
*
FROM
`e_store`.`products`
WHERE
`category_id` = 1
AND `attributes` -> '$.ports.usb' > 0
AND `attributes` -> '$.ports.hdmi' > 0;
UPDATE
InordertoupdateJSONvalues,wearegoingtousethe JSON_INSERT ,
JSON_REPLACE ,and JSON_SET functions.Thesefunctionsalsorequirea
pathexpressiontospecifywhichpartsoftheJSONobjectto
modify.
TheoutputofthesefunctionsisavalidJSONobjectwiththe
changesapplied.
Letusmodifyallmobilephonestohaveachipsetpropertyaswell.
SQL
UPDATE `e_store`.`products`
SET `attributes` = JSON_INSERT(
`attributes` ,
'$.chipset' ,
'Qualcomm'
)
WHERE
`category_id` = 2;
(https://hrd.cm/2k90ljr)
The $.chipset pathexpressionidentifiesthepositionofthe chipset
propertytobeattherootoftheobject.
SQL
UPDATE `e_store`.`products`
SET `attributes` = JSON_REPLACE(
`attributes` ,
'$.chipset' ,
'Qualcomm Snapdragon'
)
WHERE
`category_id` = 2;
Easypeasy!
SQL
UPDATE `e_store`.`products`
SET `attributes` = JSON_SET(
`attributes` ,
'$.body_color' ,
'red'
)
WHERE
`category_id` = 1;
(https://hrd.cm/2k90ljr)
Allofthesefunctionsseemidenticalbutthereisadifferenceinthe
waytheybehave.
DELETE
Therearetwopartstodeletingthatwewilllookat.
Thefirstistodeleteacertainkey/valuefromyourJSONcolumns
whereasthesecondistodeleterowsusingaJSONcolumn.
SQL
UPDATE `e_store`.`products`
SET `attributes` = JSON_REMOVE(`attributes` , '$.mount_type')
WHERE
`category_id` = 3;
Forthesecondcase,wealsodonotprovidemobilephones
(https://hrd.cm/2k90ljr)
anymorethathavetheJellybeanversionoftheAndroidOS.
SQL
Asstatedpreviously,workingwithaspecificattributerequiresthe
useofthe JSON_EXTRACT functionsoinordertoapplythe LIKE
operator,wehavefirstextractedthe os propertyof
mobilephones(withthehelpof category_id )anddeletedallrecords
thatcontainthestring Jellybean .
Thesedays,frameworksinsulatedevelopersfromlower-level
operationsanditalmostfeelsalienforaframeworkfanaticnotto
beabletotranslatehis/herdatabaseknowledgeintoanobject
relationalmapper.
Forthepurposeofnotleavingsuchdevelopersheartbrokenand
wonderingabouttheirexistenceandpurposeintheuniverse,we
aregoingtolookathowtogoaboutthebusinessofJSONcolumns
intheLaravelframework.
(https://hrd.cm/2k90ljr)
Wewillonlybefocusingontheparts
thatoverlapwithoursubjectmatter
whichdealswithJSONcolumns.An
in-depthtutorialontheLaravel
frameworkisbeyondthescopeof
thispiece.
BASH
(https://hrd.cm/2k90ljr)
PHP
/* database/migrations/create_brands.php */
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('brands');
}
}
/* database/migrations/create_categories.php */
<?php
(https://hrd.cm/2k90ljr)
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('categories');
}
}
(https://hrd.cm/2k90ljr)
PHP
/* database/migrations/create_products */
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
(https://hrd.cm/2k90ljr)
{
Schema::drop('products');
}
}
Payattentiontothe $table->json('attributes'); statementinthe
migration.
Justlikecreatinganyothertablefieldusingtheappropriatedata
typenamedmethod,wehavecreatedaJSONcolumnusingthe
json methodwiththename attributes .
Also,thisonlyworksfordatabaseenginesthatsupporttheJSON
datatype.
Engines,suchasolderversionsofMySQLwillnotbeabletocarry
outthesemigrations.
(https://hrd.cm/2k90ljr)
PHP
/* app/Brand.php */
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
/* app/Category.php */
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
/* app/Product.php */
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
(https://hrd.cm/2k90ljr)
class Product extends Model
{
// Cast attributes JSON to array
protected $casts = [
'attributes' => 'array'
];
Wewillseelaterinthetutorialhowthisfacilitatesustoupdate
recordsfromourcontrolleractions.
# Resource Operations
CREATING A PRODUCT
Speakingoftheadminpanel,theparameterstocreateaproduct
maybecominginthroughdifferentroutessincewehaveanumber
ofproductcategories.Youmayalsohavedifferentviewstocreate,
edit,show,anddeleteaproduct.
Forexample,aformtoaddacamerarequiresdifferentinputfields
thanaformtoaddamobilephonesotheywarrantseparateviews.
(https://hrd.cm/2k90ljr)
Moreover,onceyouhavetheuserinputdata,youwillmost
probabalyrunitthrougharequestvalidator,separateforthe
camera,andthemobilephoneeach.
ThefinalstepwouldbetocreatetheproductthroughEloquent.
Wewillbefocusingonthecameraresourcefortherestofthis
tutorial.Otherproductscanbeaddressedusingthecodeproduced
inasimilarmanner.
Assumingwearesavingacameraandtheformfieldsarenamed
astherespectivecameraattributes,hereisthecontrolleraction.
PHP
FETCHING PRODUCTS
Recallthe $casts arraywedeclaredearlierinthe Product model.It
willhelpusreadandeditaproductbytreatingattributesasan
associativearray.
(https://hrd.cm/2k90ljr)
PHP
(https://hrd.cm/2k90ljr)
HTML
<table>
<tr>
<td>Name</td>
<td>{{ $camera->name }}</td>
</tr>
<tr>
<td>Brand ID</td>
<td>{{ $camera->brand_id }}</td>
</tr>
<tr>
<td>Category ID</td>
<td>{{ $camera->category_id }}</td>
</tr>
<tr>
<td>Processor</td>
<td>{{ $camera->attributes['processor'] }}</td>
</tr>
<tr>
<td>Sensor Type</td>
<td>{{ $camera->attributes['sensor_type'] }}</td>
</tr>
<tr>
<td>Monitor Type</td>
<td>{{ $camera->attributes['monitor_type'] }}</td>
</tr>
<tr>
<td>Scanning System</td>
<td>{{ $camera->attributes['scanning_system'] }}</td>
</tr>
</table>
EDITING A PRODUCT
Asshownintheprevioussection,youcaneasilyfetchaproduct
andpassittotheview,whichinthiscasewouldbetheeditview.
(https://hrd.cm/2k90ljr)
Youcanusetheproductvariabletopre-populateformfieldsonthe
editpage.
Updatingtheproductbasedontheuserinputwillbeprettysimilar
tothe store actionwesawearlier,onlythatinsteadofcreatinga
newproduct,youwillfetchitfirstfromthedatabasebefore
updatingit.
Ifyouhaveasearchpagethatallowscamerastobesearched
basedontheirspecificationsprovidedbytheuser,youcandoso
withthefollowingcode.
PHP
Theretrivedrecordswillnowbeavailabletothe product.camera.search
DELETING A PRODUCT
Usinganon-JSONcolumnattribute,youcandeleteproductsby
specifyingawhereclauseandthencallingthe delete method.
Forexample,incaseofanID.
(https://hrd.cm/2k90ljr)
PHP
\App\Product::where('id', $id)->delete();
ForJSONcolumns,specifyawhereclauseusingasingleormultiple
attributesandthencallthe delete method.
PHP
# Curtains
WehavebarelyscratchedthesurfacewhenitcomestousingJSON
columnsinMySQL.
Wheneveryouneedtosavedataaskey/valuepairsinaseparate
tableorworkwithflexibleattributesforanentity,youshould
considerusingaJSONdatatypefieldinsteadasitcanheavily
contributetocompressingyourdatabasedesign.
Ifyouareinterestedindivingdeeper,theMySQLdocumentation
(https://dev.mysql.com/doc/refman/5.7/en/json.html)isagreat
resourcetoexploreJSONconceptsfuther.
Ihopeyoufoundthistutorialinterestingandknowledgeable.Until
mynextpiece,happycoding!
(https://hrd.cm/2k90ljr)
laravel(https://scotch.io/tag/laravel) php(https://scotch.io/tag/php)
(https://pub.scotch.io/@nomanurrehman)
Next Up
(https://scotch.io/tutorials/laravel-random-keys-with-keygen)
API(https://scotch.io/tag/api) composer(https://scotch.io/tag/composer) laravel(https://scotch.io/tag/laravel) php
(https://pub.scotch.io/@gladchinda)
(https://scotch.io/tag/php) tokens(https://scotch.io/tag/tokens)
(https://hrd.cm/2k90ljr)
(https://hrd.cm/2k90ljr)
23Comments Scotch
1 Login
Jointhediscussion
Matin2daysago
FirstIwanttothanksforyourgreatandfunctionalarticle,yousavedmytime!
second:isthereanywaytohaveconstraintsonJSONfielditems?
Reply Share
NomanUrRehman>Matin5hoursago
Youarewelcome!
Constraintsasinthedatatypesallowedforanattribute?
Forexample,attributeabcshouldonlyacceptintegervalueswhereas
attributexyzshouldonlyacceptstringvalues?
Reply Share
AlbertRaj13daysago
Excellentman,thereisasmallspellmistake,thoughitsminormistakebettertobe
removed.:)
CREATINGAPRODUCT>3rdparagraph>Moreoever
Reply Share
NomanUrRehman>AlbertRaj5daysago
Thanksalotforpointingthatoutandtheappreciation:)
Reply Share
IvanEliseoTinajeroDiaz14daysago
WooMan,youreallydeserveabeer.Thanksforsharethiswonderfultutorial.
Regards
Reply Share
NomanUrRehman>IvanEliseoTinajeroDiaz5daysago
Youarewelcome:)
Reply Share
RobKumaramonthago
Aren'ttheforeignkeyconstraintsinthecreate_productsmigrationsincorrect?
Shouldn'tdeleteberestrictedandupdatebecascade?
Reply Share
NomanUrRehman>RobKumar20daysago
Thanksforpointingitout.Fixed.
Reply Share
SoftPdfamonthago
WhenItriedtoruntheselinesonphpmyadmin
CREATETABLE`e_store`.`products`(
`id`INTUNSIGNEDNOTNULLAUTO_INCREMENT,
`name`VARCHAR(250)NOTNULL,
`brand_id`INTUNSIGNEDNOTNULL,
`category_id`INTUNSIGNEDNOTNULL,
`attributes`JSONNOTNULL,
PRIMARYKEY(`id`),
INDEX`CATEGORY_ID`(`category_id`ASC),
(https://hrd.cm/2k90ljr)
INDEX`BRAND_ID`(`brand_id`ASC),
CONSTRAINT`brand_id`FOREIGNKEY(`brand_id`)REFERENCES
`e_store`.`brands`(`id`)ONDELETERESTRICTONUPDATECASCADE,
CONSTRAINT`category_id`FOREIGNKEY(`category_id`)REFERENCES
`e_store`.`categories`(`id`)ONDELETERESTRICTONUPDATECASCADE
)
IsawthefollowingError>>
#1064YouhaveanerrorinyourSQLsyntaxcheckthemanualthatcorresponds
toyourMariaDBserverversionfortherightsyntaxtousenear'JSONNOTNULL,
PRIMARYKEY(`id`),
INDEX`CATEGORY_ID`(`category_id`'atline6
Reply Share
NomanUrRehman>SoftPdfamonthago
YouareusingMariaDBwhereasthistutorialiswrittenforMySQL.
IamnotsureifMariaDBsupportsJSONcolumns.
Reply Share
ShahrozeNawaz>NomanUrRehman18daysago
YesMariaDbhasjsonfunctionstousewithcolumnsseethe
completeguideherehttps://mariadb.com/kb/en/m...
Reply Share
NomanUrRehman>ShahrozeNawaz15daysago
YourlinkpointstothedocumentationofJSONfunctionsin
theknowledgebase.
However,IcouldnotfindtheJSONdatatypeinthelisted
datatypesintheknowledgebase.
https://mariadb.com/kb/en/m...
Canyoupointtoaknowledgebaselinkthatclearlymentions
thereisaJSONdatatype?
Reply Share
ZrelliMajdi2monthsago
behindthescenedoesmysqlstoreeachjsonkeyasnewvalueorrepeatedkeywil
bereferenced
Reply Share
NomanUrRehman>ZrelliMajdi2monthsago
Thedocumentationsays:
"Optimizedstorageformat.JSONdocumentsstoredinJSONcolumnsare
convertedtoaninternalformatthatpermitsquickreadaccesstodocument
elements.WhentheserverlatermustreadaJSONvaluestoredinthis
binaryformat,thevalueneednotbeparsedfromatextrepresentation.The
binaryformatisstructuredtoenabletheservertolookupsubobjectsor
nestedvaluesdirectlybykeyorarrayindexwithoutreadingallvalues
beforeoraftertheminthedocument."
Reply Share
MichaelBOUVY2monthsago
ThanksNomanforthisexcellentarticle!
IguessusingJSON_EXTRACTfunctioninaWHEREclausemeansthatevery
singlerowofthetablehastobeprocessedtocheckifitmatches,right?Istherea
waytodefineindexesonJSONpaths?
Reply Share
OlivierDASINI>MichaelBOUVY23daysago
Verygoodarticle,onlytheindexpartismissing:)
YoucanindexJSONcontentwithGeneratedColumns.
Youcanfindmoredetailsinthisblogpost:http://dasini.net/blog/2015...
Reply Share
NomanUrRehman>MichaelBOUVY2monthsago
(https://hrd.cm/2k90ljr)
AsfarasIknow,youcannotindexJSONcolumnsdirectlyinMySQL.
However,thereisaworkaround,sortofavirtualcolumn.
Moredetailscanbefoundathttps://dev.mysql.com/doc/r...
Reply Share
NandaKumar2monthsago
NandaKumar2monthsago
AppreciatedArticle.Wellwritten.
Reply Share
NomanUrRehman>NandaKumar2monthsago
Thanks:)
Reply Share
Feras2monthsago
Howicanupgrademysqlversiononxampp?
Reply Share
NomanUrRehman>Feras2monthsago
It'sabitlongandcomplicatedprocedure.
ThebestadviceIcangiveyouisjustupdateXAMPP.
LastIchecked,theydocyclewithPHP/Apache/MySQLreleases.
Reply Share
Test2monthsago
Verygoodarticle,thanks!
Reply Share
NomanUrRehman>Test2monthsago
Youarewelcome!
Reply Share
(https://hrd.cm/2k90ljr)