This project has moved and is read-only. For the latest updates, please go here.

how to work with related data-types

Aug 4, 2015 at 5:43 PM
Hello,

I've been researching around ESENT and SQLite and after found this managed library and read the docmentation and samples I can't wait to get my hands on it :)

Actualy, I am developing a windows app that needs to have 7 data-types and persist them, there are references between these data-types and I was wondering what is the best way to persist them and load them next time by using ESENT Managed Interface?

Thanks in advance.
Aug 11, 2015 at 6:58 PM
Are you talking about more complicated data types, such as structs? Is it enough to Serialize them, and store them as opaque blobs, or did you want more functionality than that?

-martin
Aug 12, 2015 at 8:11 AM
Well actually I have a few entity classes which have properties that are all primitive value types, but some of these classes have collections of others which is used for navigation between entities, something like this:

public class ParentEntity {
public string Name { get; set; }
public IEnumerable<Child> Children { get; set; }
}

public class Child {
public int Age { get; set; }
public IEnumerable<GrandChild> Children { get; set; }
}

public class GrandChild { ... }

Does it mean that I need to convert them to strucs? if I serialize them then I might lose the possibility of effectively querying children, what is your advice?
Sep 3, 2015 at 6:26 PM
If you actually want to store people, then they should all be in the same table, and have some property like PersonIdentity.
Then you can have a single-valued column which is ParentIdentity.
And a multi-valued (tagged) column which is ChildrenIdentity.
That way you can have an arbitrary number of generations.

But I assume that they are actually pretty different objects altogether, and your Parent/Child/GrandChild example is just to give a rough idea.

An easy solution is to have each data type represented by a different table. ESE's use of multi-values makes those Enumerable columns much easier, and you don't need to do a First Normal Form to represent that.


-martin