filessources.list

sources.list  时间:2021-05-05  阅读:()
MongoDBiAbouttheTutorialMongoDBisanopen-sourcedocumentdatabaseandleadingNoSQLdatabase.
MongoDBiswritteninC++.
ThistutorialwillgiveyougreatunderstandingonMongoDBconceptsneededtocreateanddeployahighlyscalableandperformance-orienteddatabase.
AudienceThistutorialisdesignedforSoftwareProfessionalswhoarewillingtolearnMongoDBDatabaseinsimpleandeasysteps.
ItwillthrowlightonMongoDBconceptsandaftercompletingthistutorialyouwillbeatanintermediatelevelofexpertise,fromwhereyoucantakeyourselfathigherlevelofexpertise.
PrerequisitesBeforeproceedingwiththistutorial,youshouldhaveabasicunderstandingofdatabase,texteditorandexecutionofprograms,etc.
Becausewearegoingtodevelophighperformancedatabase,soitwillbegoodifyouhaveanunderstandingonthebasicconceptsofDatabase(RDBMS).
Copyright&DisclaimerCopyright2018byTutorialsPoint(I)Pvt.
Ltd.
Allthecontentandgraphicspublishedinthise-bookarethepropertyofTutorialsPoint(I)Pvt.
Ltd.
Theuserofthise-bookisprohibitedtoreuse,retain,copy,distributeorrepublishanycontentsorapartofcontentsofthise-bookinanymannerwithoutwrittenconsentofthepublisher.
Westrivetoupdatethecontentsofourwebsiteandtutorialsastimelyandaspreciselyaspossible,however,thecontentsmaycontaininaccuraciesorerrors.
TutorialsPoint(I)Pvt.
Ltd.
providesnoguaranteeregardingtheaccuracy,timelinessorcompletenessofourwebsiteoritscontentsincludingthistutorial.
Ifyoudiscoveranyerrorsonourwebsiteorinthistutorial,pleasenotifyusatcontact@tutorialspoint.
comMongoDBiiTableofContentsAbouttheTutorialiAudience.
iPrerequisites.
iCopyright&Disclaimer.
iTableofContents.
iiMONGODB.
11.
MongoDBOverview22.
MongoDBAdvantages.
43.
MongoDBEnvironment.
54.
MongoDBDataModelling105.
MongoDBCreateDatabase126.
MongoDBDropDatabase.
137.
MongoDBCreateCollection148.
MongoDBDropCollection.
169.
MongoDBDatatypes1710.
MongoDBInsertDocument.
1811.
MongoDBQueryDocument2012.
MongoDBUpdateDocument2413.
MongoDBDeleteDocument.
2614.
MongoDBProjection2815.
MongoDBLimitRecords2916.
MongoDBSortRecords3117.
MongoDBIndexing.
3218.
MongoDBAggregation3419.
MongoDBReplication.
3820.
MongoDBSharding.
4121.
MongoDBCreateBackup.
43MongoDBiii22.
MongoDBDeployment.
4523.
MongoDBJava.
4824.
MongoDBPHP.
60ADVANCEDMONGODB.
6625.
MongoDBRelationships6726.
MongoDBDatabaseReferences7027.
MongoDBCoveredQueries7228.
MongoDBAnalyzingQueries7429.
MongoDBAtomicOperations.
7630.
MongoDBAdvancedIndexing7831.
MongoDBIndexingLimitations8032.
MongoDBObjectId.
8133.
MongoDBMapReduce.
8334.
MongoDBTextSearch8635.
MongoDBRegularExpression.
8836.
MongoDBRockMongo.
9037.
MongoDBGridFS9138.
MongoDBCappedCollections9339.
MongoDBAuto-IncrementSequence95MongoDB4MongoDBMongoDB5MongoDBisacross-platform,documentorienteddatabasethatprovides,highperformance,highavailability,andeasyscalability.
MongoDBworksonconceptofcollectionanddocument.
DatabaseDatabaseisaphysicalcontainerforcollections.
Eachdatabasegetsitsownsetoffilesonthefilesystem.
AsingleMongoDBservertypicallyhasmultipledatabases.
CollectionCollectionisagroupofMongoDBdocuments.
ItistheequivalentofanRDBMStable.
Acollectionexistswithinasingledatabase.
Collectionsdonotenforceaschema.
Documentswithinacollectioncanhavedifferentfields.
Typically,alldocumentsinacollectionareofsimilarorrelatedpurpose.
DocumentAdocumentisasetofkey-valuepairs.
Documentshavedynamicschema.
Dynamicschemameansthatdocumentsinthesamecollectiondonotneedtohavethesamesetoffieldsorstructure,andcommonfieldsinacollection'sdocumentsmayholddifferenttypesofdata.
ThefollowingtableshowstherelationshipofRDBMSterminologywithMongoDB.
RDBMSMongoDBDatabaseDatabaseTableCollectionTuple/RowDocumentcolumnFieldTableJoinEmbeddedDocumentsPrimaryKeyPrimaryKey(Defaultkey_idprovidedbymongodbitself)DatabaseServerandClientMysqld/Oraclemongod1.
MongoDBOverviewMongoDB6mysql/sqlplusmongoSampleDocumentFollowingexampleshowsthedocumentstructureofablogsite,whichissimplyacommaseparatedkeyvaluepair.
{_id:ObjectId(7df78ad8902c)title:'MongoDBOverview',description:'MongoDBisnosqldatabase',by:'tutorialspoint',url:'http://www.
tutorialspoint.
com',tags:['mongodb','database','NoSQL'],likes:100,comments:[{user:'user1',message:'Myfirstcomment',dateCreated:newDate(2011,1,20,2,15),like:0},{user:'user2',message:'Mysecondcomments',dateCreated:newDate(2011,1,25,7,45),like:5}]}_idisa12byteshexadecimalnumberwhichassurestheuniquenessofeverydocument.
Youcanprovide_idwhileinsertingthedocument.
Ifyoudon'tprovidethenMongoDBprovidesauniqueidforeverydocument.
These12bytesfirst4bytesforthecurrenttimestamp,next3bytesformachineid,next2bytesforprocessidofMongoDBserverandremaining3bytesaresimpleincrementalVALUE.
MongoDB7Anyrelationaldatabasehasatypicalschemadesignthatshowsnumberoftablesandtherelationshipbetweenthesetables.
WhileinMongoDB,thereisnoconceptofrelationship.
AdvantagesofMongoDBoverRDBMSSchemaless:MongoDBisadocumentdatabaseinwhichonecollectionholdsdifferentdocuments.
Numberoffields,contentandsizeofthedocumentcandifferfromonedocumenttoanother.
Structureofasingleobjectisclear.
Nocomplexjoins.
Deepquery-ability.
MongoDBsupportsdynamicqueriesondocumentsusingadocument-basedquerylanguagethat'snearlyaspowerfulasSQL.
Tuning.
Easeofscale-out:MongoDBiseasytoscale.
Conversion/mappingofapplicationobjectstodatabaseobjectsnotneeded.
Usesinternalmemoryforstoringthe(windowed)workingset,enablingfasteraccessofdata.
WhyUseMongoDBDocumentOrientedStorage:DataisstoredintheformofJSONstyledocuments.
IndexonanyattributeReplicationandhighavailabilityAuto-shardingRichqueriesFastin-placeupdatesProfessionalsupportbyMongoDBWheretoUseMongoDBBigDataContentManagementandDeliveryMobileandSocialInfrastructure2.
MongoDBAdvantagesMongoDB8UserDataManagementDataHubMongoDB9LetusnowseehowtoinstallMongoDBonWindows.
InstallMongoDBonWindowsToinstallMongoDBonWindows,firstdownloadthelatestreleaseofMongoDBfromhttp://www.
mongodb.
org/downloads.
MakesureyougetcorrectversionofMongoDBdependinguponyourWindowsversion.
TogetyourWindowsversion,opencommandpromptandexecutethefollowingcommand.
C:\>wmicosgetosarchitectureOSArchitecture64-bitC:\>32-bitversionsofMongoDBonlysupportdatabasessmallerthan2GBandsuitableonlyfortestingandevaluationpurposes.
Nowextractyourdownloadedfiletoc:\driveoranyotherlocation.
Makesurethenameoftheextractedfolderismongodb-win32-i386-[version]ormongodb-win32-x86_64-[version].
Here[version]istheversionofMongoDBdownload.
Next,openthecommandpromptandrunthefollowingcommand.
C:\>movemongodb-win64-*mongodb1dir(s)moved.
C:\>IncaseyouhaveextractedtheMongoDBatdifferentlocation,thengotothatpathbyusingcommandcdFOOLDER/DIRandnowruntheabovegivenprocess.
MongoDBrequiresadatafoldertostoreitsfiles.
ThedefaultlocationfortheMongoDBdatadirectoryisc:\data\db.
SoyouneedtocreatethisfolderusingtheCommandPrompt.
Executethefollowingcommandsequence.
C:\>mddataC:\mddata\dbIfyouhavetoinstalltheMongoDBatadifferentlocation,thenyouneedtospecifyanalternatepathfor\data\dbbysettingthepathdbpathinmongod.
exe.
Forthesame,issuethefollowingcommands.
3.
MongoDBEnvironmentMongoDB10Inthecommandprompt,navigatetothebindirectorypresentintheMongoDBinstallationfolder.
SupposemyinstallationfolderisD:\setup\mongodbC:\Users\XYZ>d:D:\>cd"setup"D:\setup>cdmongodbD:\setup\mongodb>cdbinD:\setup\mongodb\bin>mongod.
exe--dbpath"d:\setup\mongodb\data"Thiswillshowwaitingforconnectionsmessageontheconsoleoutput,whichindicatesthatthemongod.
exeprocessisrunningsuccessfully.
NowtoruntheMongoDB,youneedtoopenanothercommandpromptandissuethefollowingcommand.
D:\setup\mongodb\bin>mongo.
exeMongoDBshellversion:2.
4.
6connectingto:test>db.
test.
save({a:1})>db.
test.
find(){"_id":ObjectId(5879b0f65a56a454),"a":1}>ThiswillshowthatMongoDBisinstalledandrunsuccessfully.
NexttimewhenyourunMongoDB,youneedtoissueonlycommands.
D:\setup\mongodb\bin>mongod.
exe--dbpath"d:\setup\mongodb\data"D:\setup\mongodb\bin>mongo.
exeInstallMongoDBonUbuntuRunthefollowingcommandtoimporttheMongoDBpublicGPGkeysudoapt-keyadv--keyserverhkp://keyserver.
ubuntu.
com:80--recv7F0CEB10Createa/etc/apt/sources.
list.
d/mongodb.
listfileusingthefollowingcommand.
echo'debhttp://downloads-distro.
mongodb.
org/repo/ubuntu-upstartdist10gen'|sudotee/etc/apt/sources.
list.
d/mongodb.
listNowissuethefollowingcommandtoupdatetherepositorysudoapt-getupdateMongoDB11NextinstalltheMongoDBbyusingthefollowingcommandapt-getinstallmongodb-10gen=2.
2.
3Intheaboveinstallation,2.
2.
3iscurrentlyreleasedMongoDBversion.
Makesuretoinstallthelatestversionalways.
NowMongoDBisinstalledsuccessfully.
StartMongoDBsudoservicemongodbstartStopMongoDBsudoservicemongodbstopRestartMongoDBsudoservicemongodbrestartTouseMongoDBrunthefollowingcommand.
mongoThiswillconnectyoutorunningMongoDBinstance.
MongoDBHelpTogetalistofcommands,typedb.
help()inMongoDBclient.
Thiswillgiveyoualistofcommandsasshowninthefollowingscreenshot.
MongoDB12MongoDB13MongoDBStatisticsTogetstatsaboutMongoDBserver,typethecommanddb.
stats()inMongoDBclient.
Thiswillshowthedatabasename,numberofcollectionanddocumentsinthedatabase.
Outputofthecommandisshowninthefollowingscreenshot.
MongoDB14DatainMongoDBhasaflexibleschema.
documentsinthesamecollection.
Theydonotneedtohavethesamesetoffieldsorstructure,andcommonfieldsinacollection'sdocumentsmayholddifferenttypesofdata.
SomeconsiderationswhiledesigningSchemainMongoDBDesignyourschemaaccordingtouserrequirements.
Combineobjectsintoonedocumentifyouwillusethemtogether.
Otherwiseseparatethem(butmakesurethereshouldnotbeneedofjoins).
Duplicatethedata(butlimited)becausediskspaceischeapascomparetocomputetime.
Dojoinswhilewrite,notonread.
Optimizeyourschemaformostfrequentusecases.
Docomplexaggregationintheschema.
ExampleSupposeaclientneedsadatabasedesignforhisblog/websiteandseethedifferencesbetweenRDBMSandMongoDBschemadesign.
Websitehasthefollowingrequirements.
Everyposthastheuniquetitle,descriptionandurl.
Everypostcanhaveoneormoretags.
Everyposthasthenameofitspublisherandtotalnumberoflikes.
Everyposthascommentsgivenbyusersalongwiththeirname,message,data-timeandlikes.
Oneachpost,therecanbezeroormorecomments.
InRDBMSschema,designforaboverequirementswillhaveminimumthreetables.
4.
MongoDBDataModellingMongoDB15WhileinMongoDBschema,designwillhaveonecollectionpostandthefollowingstructure:{_id:POST_IDtitle:TITLE_OF_POST,description:POST_DESCRIPTION,by:POST_BY,url:URL_OF_POST,tags:[TAG1,TAG2,TAG3],likes:TOTAL_LIKES,comments:[{user:'COMMENT_BY',message:TEXT,dateCreated:DATE_TIME,like:LIKES},{user:'COMMENT_BY',message:TEXT,dateCreated:DATE_TIME,like:LIKES}]}MongoDB16Sowhileshowingthedata,inRDBMSyouneedtojointhreetablesandinMongoDB,datawillbeshownfromonecollectiononly.
MongoDB17Inthischapter,wewillseehowtocreateadatabaseinMongoDB.
TheuseCommandMongoDBuseDATABASE_NAMEisusedtocreatedatabase.
Thecommandwillcreateanewdatabaseifitdoesn'texist,otherwiseitwillreturntheexistingdatabase.
SyntaxBasicsyntaxofuseDATABASEstatementisasfollows:useDATABASE_NAMEExampleIfyouwanttocreateadatabasewithname,thenuseDATABASEstatementwouldbeasfollows:>usemydbswitchedtodbmydbTocheckyourcurrentlyselecteddatabase,usethecommanddb>dbmydbIfyouwanttocheckyourdatabaseslist,usethecommandshowdbs.
>showdbslocal0.
78125GBtest0.
23012GBYourcreateddatabase(mydb)isnotpresentinlist.
Todisplaydatabase,youneedtoinsertatleastonedocumentintoit.
>db.
movie.
insert({"name":"tutorialspoint"})>showdbslocal0.
78125GBmydb0.
23012GB5.
MongoDBCreateDatabaseMongoDB18test0.
23012GBInMongoDBdefaultdatabaseistest.
Ifyoudidn'tcreateanydatabase,thencollectionswillbestoredintestdatabase.
MongoDB19Inthischapter,wewillseehowtodropadatabaseusingMongoDBcommand.
ThedropDatabase()MethodMongoDBdb.
dropDatabase()commandisusedtodropaexistingdatabase.
SyntaxBasicsyntaxofdropDatabase()commandisasfollows:db.
dropDatabase()Thiswilldeletetheselecteddatabase.
Ifyouhavenotselectedanydatabase,thenitwilldeletedefault'test'database.
ExampleFirst,checkthelistofavailabledatabasesbyusingthecommand,showdbs.
>showdbslocal0.
78125GBmydb0.
23012GBtest0.
23012GB>Ifyouwanttodeletenewdatabase,thendropDatabase()commandwouldbeasfollows:>usemydbswitchedtodbmydb>db.
dropDatabase()>{"dropped":"mydb","ok":1}>Nowchecklistofdatabases.
>showdbslocal0.
78125GBtest0.
23012GB>6.
MongoDBDropDatabaseMongoDB20Inthischapter,wewillseehowtocreateacollectionusingMongoDB.
ThecreateCollection()MethodMongoDBdb.
createCollection(name,options)isusedtocreatecollection.
SyntaxBasicsyntaxofcreateCollection()commandisasfollows:db.
createCollection(name,options)Inthecommand,nameisnameofcollectiontobecreated.
Optionsisadocumentandisusedtospecifyconfigurationofcollection.
ParameterTypeDescriptionNameStringNameofthecollectiontobecreatedOptionsDocument(Optional)SpecifyoptionsaboutmemorysizeandindexingOptionsparameterisoptional,soyouneedtospecifyonlythenameofthecollection.
Followingisthelistofoptionsyoucanuse:FieldTypeDescriptioncappedBoolean(Optional)Iftrue,enablesacappedcollection.
Cappedcollectionisafixedsizecollectionthatautomaticallyoverwritesitsoldestentrieswhenitreachesitsmaximumsize.
Ifyouspecifytrue,youneedtospecifysizeparameteralso.
autoIndexIDBoolean(Optional)Iftrue,automaticallycreateindexon_idfield.
Defaultvalueisfalse.
sizenumber(Optional)Specifiesamaximumsizeinbytesforacappedcollection.
Ifcappedistrue,thenyouneedtospecifythisfieldalso.
7.
MongoDBCreateCollectionMongoDB21maxnumber(Optional)Specifiesthemaximumnumberofdocumentsallowedinthecappedcollection.
Whileinsertingthedocument,MongoDBfirstcheckssizefieldofcappedcollection,thenitchecksmaxfield.
ExamplesBasicsyntaxofcreateCollection()methodwithoutoptionsisasfollows:>usetestswitchedtodbtest>db.
createCollection("mycollection"){"ok":1}>Youcancheckthecreatedcollectionbyusingthecommandshowcollections.
>showcollectionsmycollectionsystem.
indexesThefollowingexampleshowsthesyntaxofcreateCollection()methodwithfewimportantoptions:>db.
createCollection("mycol",{capped:true,autoIndexID:true,size:6142800,max:10000}){"ok":1}>InMongoDB,youdon'tneedtocreatecollection.
MongoDBcreatescollectionautomatically,whenyouinsertsomedocument.
>db.
tutorialspoint.
insert({"name":"tutorialspoint"})>showcollectionsmycolmycollectionsystem.
indexestutorialspoint>MongoDB22EndofebookpreviewIfyoulikedwhatyousaw…Buyitfromourstore@https://store.
tutorialspoint.
com

妮妮云香港CTG云服务器1核 1G 3M19元/月

香港ctg云服务器香港ctg云服务器官网链接 点击进入妮妮云官网优惠活动 香港CTG云服务器地区CPU内存硬盘带宽IP价格购买地址香港1核1G20G3M5个19元/月点击购买香港2核2G30G5M10个40元/月点击购买香港2核2G40G5M20个450元/月点击购买香港4核4G50G6M30个80元/月点击购买香...

VirtVPS抗投诉瑞士VPS上线10美元/月

专心做抗投诉服务器的VirtVPS上线瑞士机房,看中的就是瑞士对隐私的保护,有需要欧洲抗投诉VPS的朋友不要错过了。VirtVPS这次上新的瑞士服务器采用E-2276G处理器,Windows/Linux操作系统可选。VirtVPS成立于2018年,主营荷兰、芬兰、德国、英国机房的离岸虚拟主机托管、VPS、独立服务器、游戏服务器和外汇服务器业务。VirtVPS 提供世界上最全面的安全、完全受保护和私...

[6.18]IMIDC:香港/台湾服务器月付30美元起,日本/俄罗斯服务器月付49美元起

IMIDC发布了6.18大促销活动,针对香港、台湾、日本和莫斯科独立服务器提供特别优惠价格最低月付30美元起。IMIDC名为彩虹数据(Rainbow Cloud),是一家香港本土运营商,全线产品自营,自有IP网络资源等,提供的产品包括VPS主机、独立服务器、站群独立服务器等,数据中心区域包括香港、日本、台湾、美国和南非等地机房,CN2网络直连到中国大陆。香港服务器   $39/...

sources.list为你推荐
支持ipadphpweb破解宽带无线网是WPAPSK会被破解吗Joinsql客服电话赶集网客服电话是多少抢米网怎么样才能在小米官方网站抢到手机?piaonimai跪求朴妮唛的的韩文歌,不知道是哪一部的,第一首放的是Girl's Day《Oh! My God》。求第三首韩文歌曲,一男一女唱的。温州都市报招聘温州哪里有招暑期工?怎么去?要什么条件?急......discuz伪静态求虚拟主机Discuz 伪静态设置方法欢迎光临本店鸡蛋蔬菜饺子每个10个3元,牛肉蔬菜饺子每10个5元,欢迎光临本店! 汉译英网站后台密码破解我找到了网站的后台地址,怎么才可以破解密码
免备案虚拟主机 花生壳免费域名申请 flashfxp怎么用 香港cdn godaddy ibrs 智能骨干网 日本bb瘦 有奖调查 hdd 云服务器比较 百度云空间 摩尔庄园注册 广东服务器托管 镇江高防服务器 screen 挂马检测工具 rewrite规则 电脑主机声音大 vpn服务器架设 更多