I have two collections, malls and shops. I want to keep location information of them (as latitude and longitude). For malls, it is easy, because they have only one location information, so i can define latitude and longitude property. But for shops, they can be either inside a mall or on the street, and they have multiple locations. I want to keep relation between shops and malls, for the places where they are inside a mall. I want to keep locations as a separate collection (at least for the shops), otherwise the data will be very heavy when i list the shops. Locations of a selected shop would be shown (downloaded) only when necessary. So question is, how should be the data model for locations collection? I'm considering something like this, but I don't feel it is the best idea. I consider to keep the lat, lan data of mall in its collection directly for simplicity (btw, i use simple schema):
ShopLocations = new Mongo.Collection('shoplocations');
var shopsLocationsSchema = new SimpleSchema ({
name: {
type: String,
label: 'Location Name',
max: 200
},
inMall: {
type: Boolean,
label: 'Is it in the mall?',
optional: true
},
mallId: {
type: String,
label: 'Mall ID',
optional: true
},
latitude: {
type: Number,
label: 'Latitude',
decimal: true,
optional: true
},
longitude: {
type: Number,
label: 'Latitude',
decimal: true,
optional: true
}
});
ShopLocations.attachSchema(shopsLocationsSchema, {replace: true});