NoSQL 新手,对创建集合有点困惑
New to NoSQL and a little confused with creating collections
我是一名刚刚开始使用 NoSQL 的学生,但它并不适合我。我在几点上有点困惑。
任何帮助将不胜感激
1.Can 文档属于多个集合?
2.Have 我创建集合的语法正确吗?
pic 是集合 er 而 a 只是完整 er 的一个片段。
db.Animal.insert ( {
“animal_ID” : “XXXXXXX “,
“common_name” : “Red Squirrel”,
“IUCN” : “Least Concern (declining)”,
“photo” : “qs451xkx6qf4j”,
“extinct” : {
“when” : “null “,
“reason” : “null”
},
“invasive” : {
“threat_level” : “null”,
“threat” : “null”,
“how_to_help” : “null”
},
“native” : {
“endangerment” : “population declining“,
“how_to_help” : “providing a little extra food, planting some red squirrel-friendly shrubs and reporting any red or grey squirrel activity”
},
“Fact_sheet” : “{
“fact_id” : “ “,
“animal_id” : “ XXXXXXX “,
“order” : “ Rodentia “,
“family” : “Sciuridae “ ,
“species” : “Sciurus vulgaris “ ,
“size” : “body length 19 to 23 cm, tail length 15 to 20 cm “ ,
“weight” : “250 to 340 g “ ,
“lifespan” : “3 years , 7 to 10 in captivity “ ,
“extra” : “In Norse mythology, Ratatoskr is a red squirrel who runs up and down with messages in the world tree, Yggdrasil, and spreads gossip “ ,
“habitat” : { [
“name” : “woodland “,
“description” : “a low-density forest forming open habitats with plenty of sunlight and limited shade “
]
});
Can documents belong to multiple collections?
在MongoDB中,没有。在其他数据库中,我不知道。
2.Have I the correct syntax here for creating the Collection?
要创建一个集合,您可以使用 https://docs.mongodb.com/manual/reference/method/db.createCollection/。此调用还允许您传递各种收集选项。
您正在插入文档。在MongoDB插入文档时,如果目标集合不存在,则由服务器自动创建。
我是一名刚刚开始使用 NoSQL 的学生,但它并不适合我。我在几点上有点困惑。 任何帮助将不胜感激 1.Can 文档属于多个集合?
2.Have 我创建集合的语法正确吗? pic 是集合 er 而 a 只是完整 er 的一个片段。
db.Animal.insert ( {
“animal_ID” : “XXXXXXX “,
“common_name” : “Red Squirrel”,
“IUCN” : “Least Concern (declining)”,
“photo” : “qs451xkx6qf4j”,
“extinct” : {
“when” : “null “,
“reason” : “null”
},
“invasive” : {
“threat_level” : “null”,
“threat” : “null”,
“how_to_help” : “null”
},
“native” : {
“endangerment” : “population declining“,
“how_to_help” : “providing a little extra food, planting some red squirrel-friendly shrubs and reporting any red or grey squirrel activity”
},
“Fact_sheet” : “{
“fact_id” : “ “,
“animal_id” : “ XXXXXXX “,
“order” : “ Rodentia “,
“family” : “Sciuridae “ ,
“species” : “Sciurus vulgaris “ ,
“size” : “body length 19 to 23 cm, tail length 15 to 20 cm “ ,
“weight” : “250 to 340 g “ ,
“lifespan” : “3 years , 7 to 10 in captivity “ ,
“extra” : “In Norse mythology, Ratatoskr is a red squirrel who runs up and down with messages in the world tree, Yggdrasil, and spreads gossip “ ,
“habitat” : { [
“name” : “woodland “,
“description” : “a low-density forest forming open habitats with plenty of sunlight and limited shade “
]
});
Can documents belong to multiple collections?
在MongoDB中,没有。在其他数据库中,我不知道。
2.Have I the correct syntax here for creating the Collection?
要创建一个集合,您可以使用 https://docs.mongodb.com/manual/reference/method/db.createCollection/。此调用还允许您传递各种收集选项。
您正在插入文档。在MongoDB插入文档时,如果目标集合不存在,则由服务器自动创建。