前言 导师让我看一些NoSQL资料,于是目标锁定了MongoDB,至于为什么,很简单,发现了一些不错的资料。看了一些资料,有一些想法或者读后感吧,记下来,以备回忆。 简介 MongoDB是面向集合、模式自由的文档型数据库。 面向集合(collection),文档(document)而
前言
导师让我看一些NoSQL资料,于是目标锁定了MongoDB,至于为什么,很简单,发现了一些不错的资料。看了一些资料,有一些想法或者读后感吧,记下来,以备回忆。
简介MongoDB是面向集合、模式自由的文档型数据库。
面向集合(collection),文档(document)而不是面向表(table),行(row)。文档型数据库是指数据库里面的数据库格式是BSON,与Json有些类似。MongoDB只是NoSQL的一种,那么为什么要用非关系型数据库呢?
逻辑结构和存储结构逻辑结构:
关系型数据库:一个数据库实例包含多个database,一个database包含多个table,一个table包括多个rows。
MongoDB:一个MongoDB实例包含多个database,一个database包括多个collection,一个collection包括多个document。
存储结构:
关系型数据库:创建一个普通数据库生成两个文件:.mdf,.ldf。
MongoDB: 创建一个普通数据库生成两个文件.ns,.0文件。
此文详细介绍MongoDB数据文件内部结构以及
应用MongoDB自带交互式Javascript Shell,用来对MongoDB进行操作和管理,而且许多MongoDB爱好者也写了许多GUI MongoDB管理软件。MongoDB Shell相较于MongoDB GUIs更底层一些,封闭的更少些,因此更灵活,也更能了解原理,学起来也不是很难。
博客园的一线码农写了一个MongoDB系列很不错,里面介绍了MongoDB 的CURD操作,聚合函数,索引等相关知识。
架构
先知道what,再知道how,最后还得知道why。
介绍的很好。
1. Replica Sets 副本集
即MongoDB在多个服务器上备份数据。有一个primary DB,用户只能向primary DB写入数据,网站空间,但是可以从多个服务器读取数据库,从而可以实现读写分离。而Primary DB和 Secondary DB之间保持着心跳同步检测,保持数据库的一致性。当Primary DB宕机,有仲裁服务器会从Secondary 中选出一个来充当 Primary DB。
2. Auto-Sharding 自动分片
如果一个数据太大,磁盘吃紧,美国空间,需要对数据进行分片。
3.Auto-Sharding + Replica Sets
如此,不但可以解决海量存储和动态扩容问题,而且还可以实现高可靠,高并发。
每个Shard都是集群,
Shard1在三个服务器上都存在,可以提高可靠性,容错能力,备份恢复能力。
config在三个服务器上,也是同理,为了可靠的保存分片的元数据。
mongos在3个服务器上,可实现负载平衡,提高客户端接入性能。
步骤:客户端发起请求,有3个路由进程之一接收并解析命令,然后根据config服务器记录的分片元数据来确定需要接收客户端命令的分片。
服务器的具体配置可以参考 一线码农系列
MongoDB驱动在实际编程中,你当然可以使用process调用cmd命令来操作和管理MongoDB,但是太麻烦了,还是下载驱动方便方便,MongoDB驱动多着,当然会有C#,有官方,也有非官方的。 ?
优劣势优劣势自然是和关系型数据库对比了
参考MongoDB调查总结
MongoDB 身上的优势和劣势
自我总结学起来挺轻松的,也许接触的还不深,没有经过大型项目实战,但是学着一直有种和充实的感觉,那就是我知道为什么会这样,也许是开源的原因吧。NoSQL和关系型数据库各有优势,并立共存,香港虚拟主机,适用于不同的项目中。比如,Mongo不支持事务,对于银行转账之类的自然不适用;但是在web2.0时代,NoSQL的角色愈来愈重要了,NoSQL的优势也是为web2.0而生的。
参考资料1. NoSQLFan MongoDB资料汇总专题 略显杂乱
2. MongoDB 官网 MongoDB手册 权威,英文

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
