Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a generic relational model #18

Open
rofr opened this issue Jun 18, 2015 · 2 comments
Open

Create a generic relational model #18

rofr opened this issue Jun 18, 2015 · 2 comments

Comments

@rofr
Copy link
Member

rofr commented Jun 18, 2015

Users should be able to use the CRUD pattern to store entities objects of any type. Entities that refer to each other should use foreign keys, not references.
Something like:

  var db = Db.For<Relational>();
  db.CreateTable<Product>();
  var product = new Product();
  db.Insert(product);
  product.Name = "Coconuts";
  db.Update(product);
  db.Delete(product);

Some things to discuss:

Identity

Each entity needs to have a unique identity. We could allow a [Key] attribute on one or more fields, look for a field named Id or just let the user implement IComparable on each Entity. We could support all of these or a subset.

Generated keys

User assigned numeric keys is a problem, there is a risk for duplicates. We could just recommend guids but that takes away options from the user. Also guids use more memory than integer types.
If the server generates during INSERT we might need the generated value to set as FK in related entities. These may also have to be in the same transaction.

Constraints

Constraints should probably be on the entity itself, using plain OO. Except unique constraints, we could use indexes for that.

Indexes

Creating indexes would be useful. Something like:
db.Index<Product>("Product.Name", p => p.Name);
We would have to serialize the lambda to make this work with a remote server.

How will origodb server know the user defined entity types?

Running embedded the user can put custom entities in a generic model but remote, the server needs to be able to load the types. One way would be to just add assemblies in the server UI but this kind of defeats the purpose of a generic model in the first place.

Here's an old blog article with some ideas
http://origodb.com/2011/11/24/relational-modeling-and-crud.html
EDIT: Link updated

@TheOnlyRealTodd
Copy link

TheOnlyRealTodd commented Sep 28, 2016

Hello,

I am very interested in working on this... I have some experience using Entity Framework which uses format similar to what you described. Obviously, this will take some time and I am a junior dev so I am going to research it more and as long as it's something I can take on reasonably, I'd love to contribute!

This entire project sounds awesome actually and I have a strong interest in back-end development as well as relational databases.

Also, please note that the link is broken at the bottom of the post.

@rofr
Copy link
Member Author

rofr commented Sep 28, 2016

Awesome!

There is an embryo for relational modeling in the dev branch, you'll find it in the Modeling namespace. There is also a feature branch called f-relational-something-something with an earlier attempted implementation.

Fork the repo, start playing around and let's discuss details here or on gitter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants