我刚刚进入NoSQL数据库,特别是MongoDB。我与SQL一起工作了很多年,所以我习惯了更传统的方法。Mongo文档查询
我有一个Json包,用于存储我想要为公寓收集的所有细节。我想我的问题是,我将这一切全部存储为一个记录(文档),还是应该将它分解为不同的集合/文档并将它们组合在一起进行一些操作。
这里是我的JSON
{
"Title": "First Class 8 bedroom home- resort-Exceptional decor and furnishings",
"Description" : "The Address is an eight bedroom, five bathroom Orlando vacation rental that’s located at the Champions Gate Resort – just a few minutes from the main gates of Walt Disney World!/n When you stay on property at Champions Gate, you are privy to a variety of wonderful amenities that include but aren’t limited to, a large community pool, fitness center, club house, sports courts and two championship golf courses./n The resort amenities aren’t the only draw for this property because the vacation home alone is one to write home about./n The Address has everything that you could want and more when going on vacation. Why stay at an over-crowded hotel when you can spread out and relax inside of your own private home?/n This property didn’t leave any stones unturned because every room, every bit of décor was placed with care./n Just take the open-concept main living, dining and kitchen area. The cool, light blue wall connects all three spaces into one complete area. The blue is perfectly complemented by the whites and grays which make the first floor feel even more open!/n The kitchen is fully-equipped and outfitted with stainless steel appliances and granite countertops and a five-person breakfast bar./n Next to the kitchen is your main living area with three comfortable, leather couches and a large flat-screen TV./n Your dining room is also in this space and has a 12-person dining table which proves to be the perfect place to enjoy a family meal with your loved ones!/n Right off of this area, through a sliding glass door, is your private pool area. It’s here that you can enjoy the Orlando weather as you swim around in your private pool or soak in your Jacuzzi. The covered lanai will protect you and your guests from any unwanted bugs!/n Vacations are meant to be fun, right? Well, when you’re not at the nearby Orlando attractions like, Walt Disney World, Universal Studios or Sea World, or even splashing around in your own private pool or the resort’s community pool, you can keep the fun going in your games room!",
"images": [
"https://imagesus-ssl.homeaway.com/mda01/3381ed5a-f882-4efa-b246-b94f6de9618f.1.6",
"https://imagesus-ssl.homeaway.com/mda01/85a33780-4710-4815-b798-c6b6e6d0acc0.1.6",
"https://imagesus-ssl.homeaway.com/mda01/1caf0dab-9d78-45ae-910b-d4e7088d88cf.1.6",
"https://imagesus-ssl.homeaway.com/mda01/4123137e-086e-4171-9aad-d6aae14a7052.1.6"
],
"contact": {
"name": "James Privett",
"emailAddress": "[email protected]",
"skype": "james.privett",
"phone": "xxxxx xxxx"
},
"location": {
"name": "Orlando",
"latitude": 28.36433219,
"longitude": -81.55729782
},
"rooms" : [
{
"title": "Bedroom 1",
"image": "https://imagesus-ssl.homeaway.com/mda01/3381ed5a-f882-4efa-b246-b94f6de9618f.1.6",
"description": " <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ullamco laboris nisi ut aliquip ex ea commodo consequat.</p><p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, ut aliquip ex ea commodo consequat.</p> ",
"amenities": ["laundry","security","air conditioning","tv","satelite","open fire","swimming pool"]
},{
"title": "Bedroom 2",
"image": "https://imagesus-ssl.homeaway.com/mda01/85a33780-4710-4815-b798-c6b6e6d0acc0.1.6",
"description": " <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ullamco laboris nisi ut aliquip ex ea commodo consequat.</p><p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, ut aliquip ex ea commodo consequat.</p> ",
"amenities": ["laundry","security","air conditioning","tv","satelite","open fire","swimming pool"]
},{
"title": "Bedroom 3",
"image": "https://imagesus-ssl.homeaway.com/mda01/1caf0dab-9d78-45ae-910b-d4e7088d88cf.1.6",
"description": " <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ullamco laboris nisi ut aliquip ex ea commodo consequat.</p><p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, ut aliquip ex ea commodo consequat.</p> ",
"amenities": ["laundry","security","air conditioning","tv","satelite","open fire","swimming pool"]
}
]
}
您可以使用嵌入式文档或选择实现多个集合。这个线程肯定会回答你的问题:http://stackoverflow.com/questions/5373198/mongodb-relationships-embed-or-reference – RudyVerboven