Arc Forumnew | comments | leaders | submitlogin
2 points by skenney26 6045 days ago | link | parent

What does your current database look like? What relationships are you hoping to add?

I assume you're using deftem to define your database objects. I was thinking that it would helpful to have a version of deftem that automatically created defops for adding, updating, and deleting objects from a database (similar to Rails scaffolding).



1 point by wfarr 6045 days ago | link

I know someone made scaffolding work earlier, but I don't know exactly how they did it.

Anyway, ideally with templates -- in my case, one for posts and one for tags -- you'd be able to make use of this relation in a functional way with no real performance issues.

-----

3 points by drcode 6044 days ago | link

I was the one who created the scaffolding system- It does, indeed, generate the code to add/update/etc from a database. I've continued to expand the system on my own, but since there wasn't much interest in the arc forum I decided not to continue checking code into anarki for now, but may again in the future- So right now it is strictly ver 0.01, though I'm surprised others seem to manage without a scaffolding system...

As for the issue of one-many and many-many, I guess I would suggest that in a one-to-many situation I would try and store the "many" as a child field in the "one", not use two separate tables if you can get away with it (one of the advantages of a non-RDBMS is that this design is possible)

As for many-many, I would probably have two tables, then have an extra table that just maps keys to keys for the two tables. Basically, just like an RDBMS association table. (or maybe even a bidirectional table, if you need to go "both ways")

If you want to know the "official" way to store data in different relationships in a simple, purely functional, memory resident database, I'd look at HApps-ixset. This is philisophically closely aligned to what you'd need in arc and is designed by some super smart guys. Unfortunately, their documentation is wanting or I'd point you to a good link that describes how to use it.

Those are some thoughts.

-----

2 points by skenney26 6043 days ago | link

I've been thinking it might be possible to make these mappings implicit. Imagine you had a version of deftem (I'll call it defitem) that inspected the fields in your templates:

  (defitem post
    id     nil
    title  nil
    text   nil
    tags   nil)

  (defitem tag
    id     nil
    text   nil
    post   nil)
defitem would see that post has a relationship with tag and tag has a relationship with post by looking at the names of the fields in each template. Since the post field in tag is singular and the tags field in post in plural, it would know that there is a one-to-many relationship between post and tag. Then defitem could create any necessary accessor methods.

Anyways, that's what I've been attempting recently.

-----