couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas de Bari Embriz Garcia Rojas <nb...@dalmp.com>
Subject Re: help modelling my data (DNS zones)
Date Thu, 08 Oct 2015 12:52:14 GMT
Hi tried to save a record with this format:

_id = ["com","domain"]

but get an error: {"error":"bad_request","reason":"Document id must be a
string"}

but If I am right I could use that approach for another bar something like:


my_reverse_id = ["com","domain"]

and

_id = 'com.domain'

or any best practice ?


On Thu, Oct 8, 2015 at 11:03 AM, Stefan Klein <st.fankl.in@gmail.com> wrote:

> Hi
>
> 2015-10-08 10:27 GMT+02:00 Nicolas de Bari Embriz Garcia Rojas
> <nbari@dalmp.com>:
> > 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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message