I'm working to implement a database to provide data to some decisions support tools for agriculture. Well, I've been learning about mongoDB and its best applications practices (blog.engineyard.com/2011/mongodb-best-practices, http://s3.amazonaws.com/info-mongodb-com/MongoDB-Performance-Best-Practices.pdf) but I'm still having some questions about the best way to design the database. Actually, I see many different possibilities, even here (stackoverflow.com/questions/5373198/mongodb-relationships-embed-or-reference).
My database needs to store a big quantity of data. I'm gonna have a lot of weather stations where each one has a lot of data. You can see my schemes below.
This is to store the weather stations. I've created one object called location that contains country, state, city and county. Sometimes I need to find stations by country, sometimes by state and so on...
var weatherStationSchema = new mongoose.Schema({
name: String,
active: {
type: Boolean,
default: true
},
private: {
type: Boolean,
default: false
},
organization: {
type: mongoose.Schema.ObjectId,
ref: 'Organization'
},
location: {
country: {
type: mongoose.Schema.ObjectId,
ref: 'Country',
required: true
},
state: {
type: mongoose.Schema.ObjectId,
ref: 'State',
required: true
},
city: {
type: mongoose.Schema.ObjectId,
ref: 'City'
},
county: {
type: mongoose.Schema.ObjectId,
ref: 'County'
},
lat: Number,
lon: Number,
utcOffset: Number,
zoneName: String
},
metaData: {},
__v: {
type: Number,
select: false
}
});
var WeatherStation = mongoose.model('WeatherStation', weatherStationSchema);
So, this is my data's document scheme. What is the problem? I'm gonna have a lot of data inside this document. I did some tests and I realize that going through this way. I'll be able to store 106.000 records (Understanding MongoDB BSON Document size limit).
var wsDataSchema = new mongoose.Schema({
weatherStation: {
type: mongoose.Schema.ObjectId,
ref: 'WeatherStation'
},
datetime: 'Moment',
utcOffset: Number,
interval: Number,
data: {
minTemp: Number,
avgTemp: Number,
maxTemp: Number,
avgHumi: Number,
winSpeed: Number,
SolarRad: Number
},
__v: {
type: Number,
select: false
}
});
var WsData = mongoose.model('WsData', wsDataSchema);
To solve this, I've been looking for solutions and trying to understand how is the best way to implement this kind of database with MongoDB and I'm studying about gridfs (https://www.mongodb.com/blog/post/building-mongodb-applications-binary-files-using-gridfs-part-1?_ga=1.247329284.1472580275.1437575537).
So, my question is: Should I use something like gridFS or I'm doing all wrong or... How can I work with this kind of data that exceeds the 16MB file limit.
Sorry about my this big and boring text.
Thanks all!