数据库
首页 > 数据库> > 一起学MongoDB(五)——数据库设计流程

一起学MongoDB(五)——数据库设计流程

作者:互联网

根据UI设计稿

1.确定功能模块所属集合

2.确定集合字段

UI设计稿每个展示内容对应一个字段
创建于字段
更新于字段
状态字段

最后:先中文,后英文

练习:设置存放学生信息的集合,并插入20条测试数据

1.先中文
集合名称:学生集合
集合字段:编号、学号、姓名、电话、性别、年龄、学历、备注

2.再英文
use school
for(var num=1;num<=20;num++){
	db.stu.insert({
		id:num,
		no:"QF"+num,
		name:"神龙教"+num,
		tel:"111111111",
		sex:"女",
		age:num,
		school:"研究生",
		remark:"富婆"
	})
}
> use school
switched to db school
> for(var num=1;num<=20;num++){
... db.stu.insert({
... id:num,
... no:"QF"+num,
... name:"神龙教"+num,
... tel:"111111111",
... sex:"女",
... age:num,
... school:"研究生",
... remark:"富婆"
... })
... }
WriteResult({ "nInserted" : 1 })
> db.stu.find().pretty()    # .pretty()可以格式化数据
{
        "_id" : ObjectId("6012a85dd2c06b452a1971b2"),
        "id" : 1,
        "no" : "QF1",
        "name" : "神龙教1",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 1,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971b3"),
        "id" : 2,
        "no" : "QF2",
        "name" : "神龙教2",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 2,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971b4"),
        "id" : 3,
        "no" : "QF3",
        "name" : "神龙教3",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 3,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971b5"),
        "id" : 4,
        "no" : "QF4",
        "name" : "神龙教4",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 4,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971b6"),
        "id" : 5,
        "no" : "QF5",
        "name" : "神龙教5",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 5,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971b7"),
        "id" : 6,
        "no" : "QF6",
        "name" : "神龙教6",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 6,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971b8"),
        "id" : 7,
        "no" : "QF7",
        "name" : "神龙教7",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 7,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971b9"),
        "id" : 8,
        "no" : "QF8",
        "name" : "神龙教8",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 8,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971ba"),
        "id" : 9,
        "no" : "QF9",
        "name" : "神龙教9",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 9,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971bb"),
        "id" : 10,
        "no" : "QF10",
        "name" : "神龙教10",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 10,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971bc"),
        "id" : 11,
        "no" : "QF11",
        "name" : "神龙教11",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 11,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971bd"),
        "id" : 12,
        "no" : "QF12",
        "name" : "神龙教12",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 12,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971be"),
        "id" : 13,
        "no" : "QF13",
        "name" : "神龙教13",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 13,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971bf"),
        "id" : 14,
        "no" : "QF14",
        "name" : "神龙教14",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 14,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971c0"),
        "id" : 15,
        "no" : "QF15",
        "name" : "神龙教15",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 15,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971c1"),
        "id" : 16,
        "no" : "QF16",
        "name" : "神龙教16",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 16,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971c2"),
        "id" : 17,
        "no" : "QF17",
        "name" : "神龙教17",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 17,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971c3"),
        "id" : 18,
        "no" : "QF18",
        "name" : "神龙教18",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 18,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971c4"),
        "id" : 19,
        "no" : "QF19",
        "name" : "神龙教19",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 19,
        "school" : "研究生",
        "remark" : "富婆"
}
{
        "_id" : ObjectId("6012a85dd2c06b452a1971c5"),
        "id" : 20,
        "no" : "QF20",
        "name" : "神龙教20",
        "tel" : "111111111",
        "sex" : "女",
        "age" : 20,
        "school" : "研究生",
        "remark" : "富婆"
}

标签:富婆,school,tel,name,MongoDB,数据库,id,神龙教,流程
来源: https://blog.csdn.net/weixin_44141520/article/details/113880284