Sowhythisisimportantisremember, mysequelis a relationaldatabase.
Sowhatthismeansisyouhavenumerousdifferenttableswithinyourdatabase, andeachoneofthesetablesisbutsupposedtohave a specifictypeofinformationtomakeiteasiertodealwithfrom a logicalstandpoint.
Soyoumayhave a partstableandyoumayhave a vendor's table, andyoumayhaveanorder's table, andyoumayhave a customer's tableright.
Sowhat I'm gonnabeshowingyoutodayiswe'regoingtobeusinganexampleusingsomethingcalledInnerJoin, andwe'regoingtotakethepartstableSothepartstablehas a partsaidiandhas a partsname.
Ithas a partsprice, andthenithas a connection.
Ithas a vendor's I D right.
Soinsteadofactuallyputtingalltheinformationforthevendorswithinthepartstable, you'regoingtohavein a vendor's I D.
Andthenyou'regoingtohave a vendor's table, andthatvendor's tableisgoingtohave a vendor's I D.
Andit's goingtohave a vendor's nameandisgoingtothevendorsaddress, anditcanhave a wholebunchofotherthingsthere.
Andsowhatwe'regoingtodoiswe'regoingtojointhetwotablestogether, andthenyoucanrun a selectstatementoffofthosetwotablesasifthereareonesingletable.
Sowithaninvoicetable, youcouldjoin, andsoyoucouldjustyoucouldreference a customeridea, havingallthecustomerinformationwentinthatthatthatvoicetable, youcouldreferencesimply a customer, I d.
Andthatwayyou'reoneinvoicetablecancanremainrelativelysmallanddoesn't actuallyhave a havetohave a lotofinformationinitselfbecauseit's referencingtheseothertables.
Whatwe'regoingtodoiswe'regoingtojoinbasedoffofthisvendor i D numbersothatattheendoftheday, asfarasoursequelstatementsaregonnabeconcerned, we'regoingtohaveonetable.
Sowe'regonnahavethepartstablejoinedtothevendortable, andthenhereitwillhavethepart i d.
Anotherpartname, thepartPrice.
Then I'llhavethevendor i d.
Andthenforthevendor.
It'llhave a vendor, I d.
Then I'llhavethenameandthen I'llhavetheaddress.
Andsobasically, whatwillbeabletodoiswe'llbeabletoselectsandallotherkindsof, like, mysequelstatementsbecausewe'renowgoingtobejoiningbasedoffofthatvendor i d.
Nowitisimportanttounderstand, withtheinnerjointhetypeofjointthat I'm showingyoutodaythatthisvendor I D hastobepopulatedonbothsides.
Soso 11223344 andsoon.
Ifforsomereasonthereisn't a vendor i d inoneofoneoftherecords, youwillhaveproblemsdoinganinterjoin.
Butifyouhave a vendor I d ininbothinbothcolumnsandbothrecordsinbothtables.
Sowiththat, let's gooverthecomputerso I canactuallyshowyouhowthisworkswithinmysequel.
Okay, sohereweare, backatmylabmachineagain.
I'vegot a bunchofdesktop 18.4 ItisinstalledwithaninstanceofworkableboxthatisonmyMacbookpro.
I haveusedtaskCelltoinstalltheirfulllampstack.
Sowehave a packingmysequelandPHPonthisparticularsystem, andwe'regonnagodowntothelowerlefthandcorner, clickon a showapplicationsandthenuphere, we'regonnatypeand a terminalsowecouldgetthroughtheterminal.
Andyetwenowhaveterminal.
Now, inordertologintomysequel, youshouldnowhave a useraccount.
Soin a previousclass, I showyouhowtocreatemysequeluseraccounts.
Ifyoudonothave a useraccountyetforsomereason, youcouldyousoon.
Ooh, mysequel.
Thiswilllongyouanddomysequelastherouteuser.
You'llhaveallpermissions, butwehave a normaluseraccountNow.
I'vecreated a bobuseraccountsowewillloginthatway.
Mysequel, Spacehyphen.
YouuseraccountnameitchescourtBobSpacehyphen P.
Andthenit's goingtoaskforthepassword.
And 123456 Andnowwe'reofficiallyalongintomysequelfromhere.
We'regoingtodoit, and I docontrol l Also, that's goingtoclearthescreen.
Andthefirstthingwe'regonnadoisshowDad, uh, basis.
So I wanttoseewhatdatabaseswehaveit.
It's mysequelserver s.
Sowehavethedatabases, wehavethefournormaldefaultdatabasesandthenwehavetheclass D B Class B B isthedatabasethatwe'regoingtouse.
EsoThenweusetheusecommandthrough, thengointoClass D B semicolon, ofcourse.
Andthenfromhere, Whatwe'regoingtodoiswe'regoingtodescribethetable, so d e s c onthenwe'regoingtodescribethepartstable, sothiswillshowusbasicallywhat, thetablewiththeschemaoftablelookslikewe'regoingtosemicolonon.
Okay, sowegotthefield, thedatatype, whetherit's a primarykey, anyextrainformation.
Sowehave a party, i d fieldthatisaninteger, andthatistheprimarykey, anditgetsautoincrements.
Soeverytime a newrecordiscreated, thispart I d getsimplementedbyone.
Thenwehave a partnamefieldthatistext.
Thenwehave a partpricefieldthatisfloatsoagainwhenyou'redealingwithnumbersandendis a wholenumber 10 11 550.
A floatis a decimalpointnumber 10 10.50 20.25 That's everything.
Thisisthepartprice.
We'regonnause a float, andthenwehavehisvendorideas.
Thisisthevendor.
I D.
Iswhatwe'regoingtoactuallyjoinjointwith.
Andsobasically, theideaisthatthethispartisisofferedormanufacturedorwhateverbythisvendor, I d.
Sojoiningthiswithanothertable s, we'regonnasayinter, joinoninnerjoinvendorCE, sowe'rejoiningpartswithvendorsandthenwe'regoingtosayonandthenHere's where I gettothenamingconventions.
Wedopartsdotthennorunderscore i d Sothepartstablethevendor i d field.
Sowe'rejoiningthatwhen I saythatequalsthevendor's tabledotvendorunderscoreideefield.
Andthenwe'regoinghisssemicolon.
Andhopefullyif I didn't thatfingerthisthiswillwork.
Andsowhatthatinnerjoinallowsyoutodoisitallowsyoutoconnectthosetwotablesbasedoffoftheparameteragainthevendor I d sothatyoucantheninteractwiththosetwotablesasifthey'reonesingletable.
And I thinkthemoreyouworkwithit, themoreit'llmakemakesensetoyou.
So, asalways, I enjoyedteachingthisclassand a Ford C onthenextone.
Apparently, thetypeofcontentyoujustsawisnotwhatSusan W.
WantsforthefutureofYouTube.
ThismeansthatrecommendationsbyYouTubetothischannelhavedroppedmassively, andviewsarebecoming a comicallysmall I hatetoask.
I usedtosay I wouldneverask, butifyoucouldsubscribelikecommonandmostimportantly, sharethevideosthatyouappreciate, thatmayhelpslowthedeathofthischannel.
creatingtheseclassesrequiresequipmentandservice.
Subtitles and vocabulary
Click the word to look it upClick the word to find further inforamtion about it