

db.createCollection("class_a",
{ "validator":{$jsonSchema:
{"bsonType":"object",
"properties":{"_id":{"bsonType":"string"},
"CLASS A":{"bsonType":"object",
"properties":{"attribute 1":{"bsonType": ... },
... ... ... ,
"attribute k":{"bsonType": ... },
"attribute m":{"bsonType": ... },
... ... ... ,
"attribute n":{"bsonType": ... } },
"required":["attribute 1",...,"attribute k","attribute m",...,"attribute n"],
"additionalProperties":false }
},
"required":["_id","CLASS A"],
"additionalProperties":false
} } } );

db.createCollection("student",
{ "validator":{$jsonSchema:
{"bsonType":"object",
"properties":{"_id":{"bsonType":"int"},
"STUDENT":{"bsonType":"object",
"properties":{"snumber":{"bsonType":"int" },
"first name":{"bsonType":"string" },
"last name":{"bsonType":"string" } },
"required":["snumber","first name","last name"],
"additionalProperties":false }
},
"required":["_id","STUDENT"],
"additionalProperties":false
} } } );
db.student.insert({"_id":NumberInt("1234567"),
"STUDENT":{"snumber":NumberInt("1234567"),
"first name":"Harry",
"last name":"Potter"}
} );


db.createCollection("class_a",
{ "validator":{$jsonSchema:
{"bsonType":"object",
"properties":{"_id":{"bsonType":"string"},
"CLASS A":{"bsonType":"object",
"properties":{"attribute 1":{"bsonType": ... },
... ... ... ,
"attribute k":{"bsonType": ... },
"attribute m":{"bsonType": ... },
... ... ... ,
"attribute n":{"bsonType": ... },
"attribute p":{"bsonType": ... } },
"required":["attribute 1",...,"attribute k","attribute m",...,"attribute n"],
"additionalProperties":false }
},
"required":["_id","CLASS A"],
"additionalProperties":false
} } } );

db.createCollection("student",
{ "validator":{$jsonSchema:
{"bsonType":"object",
"properties":{"_id":{"bsonType":"int"},
"STUDENT":{"bsonType":"object",
"properties":{"snumber":{"bsonType":"int" },
"first name":{"bsonType":"string" },
"last name":{"bsonType":"string" },
"date of birth":{"bsonType":"date"} },
"required":["snumber","first name","last name"],
"additionalProperties":false }
},
"required":["_id","STUDENT"],
"additionalProperties":false
} } } );
db.student.insert({"_id":NumberInt("1234567"),
"STUDENT":{"snumber":NumberInt("1234567"),
"first name":"Harry",
"last name":"Potter",
"date of birth":Date("1999-07-07")},
} );












db.createCollection("class_a",
{ "validator":{$jsonSchema:
{"bsonType":"object"
"properties":{"_id":{"bsonType":"string"},
"CLASS A":{"bsonType":"object",
"properties":{"attribute 1":{"bsonType": ... },
... ... ... ,
"attribute k":{"bsonType": ... },
"attribute m":{"bsonType": ... },
... ... ... ,
"attribute n":{"bsonType": ... },
"Related-to": {"bsonType":"object",
"properties":{"CLASS B":{"bsonType":"object",
"properties":{"attribute 1":{"bsonType": ... },
... ... ... ,
"attribute m":{"bsonType": ... },
"attribute n":{"bsonType": ... },
... ... ,
"attribute p":{"bsonType": ... } },
"required":["attribute 1",...,"attribute m","attribute n",...,"attribute p"],
"additionalProperties":false } },
"required":["CLASS B"],
"additionalProperties":false } },
"required":["attribute 1",...,"attribute k","attribute m",...,"attribute n","Related-to"],
"additionalProperties":false} },
"required":["_id","CLASS A"],
"additionalProperties":false
} } } );

db.createCollection("student",
{ "validator":{$jsonSchema:
{"bsonType":"object",
"properties":{"_id":{"bsonType":"int"},
"STUDENT":{"bsonType":"object",
"properties":{"snumber":{"bsonType":"int"},
"first name":{"bsonType":"string"},
"last name":{"bsonType":"string"},
"Owns":{"bsonType":"object",
"properties":{"CAR":{"bsonType":"object",
"properties":{"rego":{"bsonType":"string"},
"make":{"bsonType":"string"},
"model":{"bsonType":"string"} },
"required":["rego","make","model"],
"additionalProperties":false} },
"required":["CAR"],
"additionalProperties":false} },
"required":["snumber","first name","last name","Owns"],
"additionalProperties":false} },
"required":["_id","STUDENT"],
"additionalProperties":false
} } } );
db.student.insert({"_id":NumberInt("1234567"),
"STUDENT":{"snumber":NumberInt("1234567"),
"first name":"Harry",
"last name":"Potter",
"Owns":{"CAR":{"rego":"AL08UK",
"make":"Rolls Royce",
"model":"Silver Shadow"}
}
}
} );


db.createCollection("class_a",
{ "validator":{$jsonSchema:
{"bsonType":"object"
"properties":{"_id":{"bsonType":"string"},
"CLASS A":{"bsonType":"object",
"properties":{"attribute 1":{"bsonType": ... },
... ... ... ,
"attribute k":{"bsonType": ... },
"attribute m":{"bsonType": ... },
... ... ... ,
"attribute n":{"bsonType": ... },
"Related-to": {"bsonType":"array",
"items":{"bsonType":"object",
"properties":{"CLASS B":{"bsonType":"object",
"properties":{"attribute 1":{"bsonType": ... },
... ... ... ,
"attribute m":{"bsonType": ... },
"attribute n":{"bsonType": ... },
... ... ,
"attribute p":{"bsonType": ... } },
"required":["attribute 1",...,"attribute m","attribute n",...,"attribute p"],
"additionalProperties":false } },
"required":["CLASS B"],
"additionalProperties":false } },
"required":["attribute 1",...,"attribute k","attribute m",...,"attribute n","Related-to"],
"additionalProperties":false} },
"required":["_id","CLASS A"],
"additionalProperties":false } } } );

db.createCollection("lecturer",
{ "validator":{$jsonSchema:
{"bsonType":"object",
"properties":{"_id":{"bsonType":"int"},
"LECTURER":{"bsonType":"object",
"properties":{"staff number":{"bsonType":"int"},
"first name":{"bsonType":"string"},
"last name":{"bsonType":"string"},
"Owns":{"bsonType":"array",
"items":{"bsonType":"object",
"properties":{"CAR":{"bsonType":"object",
"properties":{"rego":{"bsonType":"string"},
"make":{"bsonType":"string"},
"model":{"bsonType":"string"} },
"required":["rego","make","model"],
"additionalProperties":false} },
"required":["CAR"],
"additionalProperties":false} } },
"required":["staff number","first name","last name","Owns"],
"additionalProperties":false} },
"required":["_id","LECTURER"],
"additionalProperties":false
} } } );
db.lecturer.insert({"_id":NumberInt("007"),
"LECTURER":{"staff number":NumberInt("007"),
"first name":"James",
"last name":"Bond",
"Owns":[{"CAR":{"rego":"AL08UK",
"make":"Rolls Royce",
"model":"Silver Shadow"} },
{"CAR":{"rego":"PKR856",
"make":"Mercedes",
"model";"SE800"} } ]
}
} );




db.createCollection("class_a",
{ "validator":{$jsonSchema:
{"bsonType":"object"
"properties":{"_id":{"bsonType":"string"},
"CLASS A":{"bsonType":"object",
"properties":{"attribute 1":{"bsonType": ... },
... ... ... ,
"attribute k":{"bsonType": ... },
"attribute m":{"bsonType": ... },
... ... ... ,
"attribute n":{"bsonType": ... },
"Related-to": {"bsonType":"array",
"items":{"bsonType":"object",
"properties":{"CLASS AB":{"bsonType":"object",
"properties":{"attribute-b 1":{"bsonType": ... },
... ... ... ,
"attribute-b m":{"bsonType": ... },
"Ref B" :{"bsonType": ... } },
"required":["attribute-b 1",...,"attribute-b m","Ref B"],
"additionalProperties":false } },
"required":["CLASS AB"],
"additionalProperties":false } },
"required":["attribute 1",...,"attribute k","attribute m",...,"attribute n","Related-to"],
"additionalProperties":false} },
"required":["_id","CLASS A"],
"additionalProperties":false } } } );
db.createCollection("class_b",
{ "validator":{$jsonSchema:
{"bsonType":"object"
"properties":{"_id":{"bsonType":"string"},
"CLASS B":{"bsonType":"object",
"properties":{"attribute 1":{"bsonType": ... },
... ... ... ,
"attribute m":{"bsonType": ... },
"attribute n":{"bsonType": ... },
... ... ... ,
"attribute p":{"bsonType": ... } },
"required":["attribute 1",...,"attribute m","attribute n",...,"attribute p"],
"additionalProperties":false} },
"required":["_id","CLASS B"],
"additionalProperties":false } } } );


db.createCollection("lecturer",
{ "validator":{$jsonSchema:
{"bsonType":"object"
"properties":{"_id":{"bsonType":"string"},
"LECTURER":{"bsonType":"object",
"properties":{"staff number":{"bsonType":"int" },
"first name":{"bsonType":"string"},
"last name":{"bsonType":"string" },
"Performs": {"bsonType":"array",
"items":{"bsonType":"object",
"properties":{"USAGE":{"bsonType":"object",
"properties":{"rego":{"bsonType":"string"},
"when used":{"bsonType":"date"} },
"required":["rego","when used"],
"additionalProperties":false } },
"required":["USAGE"],
"additionalProperties":false } },
"required":["staff number","first name","last name","Performs"],
"additionalProperties":false} },
"required":["_id","LECTURER"],
"additionalProperties":false } } } );
db.createCollection("car",
{ "validator":{$jsonSchema:
{"bsonType":"object",
"properties":{"_id":{"bsonType":"string"},
"CAR":{"bsonType":"object",
"properties":{"rego":{"bsonType":"string" },
"make":{"bsonType":"string" },
"model":{"bsonType":"string" } },
"required":["rego","make","model"],
"additionalProperties":false }
},
"required":["_id","CAR"],
"additionalProperties":false
} } } );
db.lecturer.insert({"_id":NumberInt("007"),
"LECTURER":{"staff number":NumberInt("007"),
"first name":"James",
"last name":"Bond",
"Performs":[ {"USAGE":{"rego":"AL08UK",
"when used":Date("2017-07-08")} },
{"USAGE":{"rego":"PKR856",
"when used":Date("2017-07-09")} },
{"USAGE":{"rego":"AL08UK",
"when used":Date("2017-07-09")} } ]
}
} );
db.car.insert({"_id":"AL08UK",
"CAR":{"rego":"AL08UK","make":"Honda","model":"Legend"}
} );
db.car.insert({"_id":"PKR856",
"CAR":{"rego":"PKR856","make":"Rolls Royce","model":"Silver Shadow"}
} );







"A"
...
"B"
...
"C":{"REF":"e"},
...
"D"...
"F"...
"E":{"_id":"e", ... }

"E"
...
"C":{"REF":"b"}
...
"D"
"F"
"A"
...
"B":{"ID":"b", ... }

"A"
...
"B"
...
"C":{"ID":"c"},
...
"D"...
"F"...
"E":[{"REF":"c"}, ...]

"E"
...
"C":{"ID":"c"}
...
"D"
"F"
"A"
...
"B":[{"REF":"c"}, ... ]



