Hi

2015-10-08 10:27 GMT+02:00 Nicolas de Bari Embriz Garcia Rojas
<[email protected]>:
> Hi all, I would like to model my data in a way that I could take full
> advantage of CouchDB, but I need some help to properly
> "normalise/decompose" etc.

[ ... ]

> I am wondering if is posible to  create a document per each record and use
> a parent-child schema, rather than creating a single document for all the
> records, maybe something like
>
> _id = domain.com (parent document)
>
> _id = sub.domain.com (child document)
> _id = www.domain.com (child document)
> etc ...
>
> This seems the way to go, but for putting all the data together, how could
> I query the database to build the entire zone, I mean how to get all the
> documents "join" so that I can form from all the chunks a single zone.


I have no idea about specific requirements for DNS, but in my opinion
hierarchical data call for this aproach:

I would save the records as an reversed array, like:

_id = ["com","domain"]
_id = ["com","domain","sub"]
_id = ["com","domain","www"]

Or if you want need multiple records in one document (see below)

records = [
["com","domain"],
["com","domain","sub"],
["com","domain","www"]
]


These you can just emit as the key to a view, so now you can query the
view for example using:
startkey=["com"]&endkey=["com",{}]
and get the full zone. Or use:
startkey=["com","domain"]&endkey=["com","domain",{}]
and just get the domain and all sub domains.

for the view it doesn't matter if you have one document per record or
one document per domain or even multiple documents per domain
including multiple records each.
So you could use the "document level" f.e. for access rights, maybe
all mail related records for a domain in one document or something
like that.

hth,
Stefan

Reply via email to