I am trying to create a database that can be used to store lots of objects. I was trying to do this with a relational database however it seems to be a bit of a beast. I mean take the simple object below
Object = {
"Type":"Car",
"Color":"Green",
"Doors":3,
Wheels:{
"Material":"Alloy",
"Size":17,
"Color":"Black",
"Tyres":{
"Profile":"Low",
"Material":"Rubber"
"Tread":"Slick"
}
},
Seats:{
"Number":2,
"Seatbelts":true
}
}
From these you could picture a 3 door green car, with black 17inch alloy wheels, low profile, slick rubber tyres, 2 seats with seatbelts. Obviously, this whole object is not set in stone, you could go and then expand upon things
(eg.
Seatbelt:{
"Type":"Harness",
"Buckles":1,
"Color":"Blue"
}
)
Eventually, assuming there are a lot of objects, I would want to return a list of objects that have these characteristics
{
"Type":"Car"
"Doors":3
}
From this I may get a list of 5 cars back that have 3 doors but have various other attributes, it doesn't matter, I haven't specified these criteria. I could narrow it down further, looking for all 3 door cars with slick tyres... I might get back 2
{
"Type":"Car"
"Doors":3
"Wheels":{
"Tyres":{
"Tread":"Slick"
}
}
}
So I was thinking a database having 3 main tables: objects, attributes and values. Then having linking tables, linking objects to attributes, attributes to values. However, what if, like in the example I have objects containing objects, and also if I plan on having an object of car which the example could be an extension of?
How do we deal with this type of database problem? Can it be done with a relational database or do I need an object oriented one? If so, are there any OODBs that I can implement with a website as easily as I can MySQL.
If you can use a RDB to do this, then queries, surely they would be very resource intensive? How about OODBs? As resource intensive?
How can I make a Object Oriented DB for a website? using RDB or OODB, I don't mind, it's just how
I would take a look at hibernate (for Java) or nhibernate (for .net). http://www.hibernate.org
Hibernate provides ORM (Object Relational Mapping) for relational databases (like MySql)
Another solution (which I personally don't like) for small amounts of data are xml files, you can then parse the data with xpath expressions. http://www.w3schools.com/xpath