I've built a nice repository layer around a db4o database to store Product
objects, which relate to Manufacturer
objects in a one-to-many relationship, i.e.:
public class Manufacturer
{
public string Name { get; set; }
}
public class Product // simplified
{
public string Name { get; set; }
Manufacturer Manufacturer { get; set; }
}
So far I really like db4o. The problem I have is preventing data duplication without resorting to IDs.
When implementing references like manufacturers using SQL Server, my data models would contain a unique ID field, and in turn my Product
class would be dirtied up with a ManufacturerID. I imagined that using an object database like db4o would reduce the impedance mismatch between a relational DB and objects, but without IDs, there is no way to tell one object from another when editing it.
Is there an elegant way to share a manufacturer between products without duplicating data? Or should I just use a relational DB?