Database / CouchDB Interview Questions
What data model does CouchDB use and how is a document structured?
CouchDB uses a document data model: all data is stored as discrete JSON objects grouped into databases. There is no enforced schema — documents in the same database can have entirely different fields.
Every CouchDB document has two mandatory system fields:
_id— the unique primary key. If omitted, CouchDB generates a UUID. Typed prefix conventions like"order:2024-001"co-locate related documents in the B-tree._rev— the current revision token in the format{generation}-{md5hash}. You must supply the current_revon every update or delete.
{
"_id": "order:2024-00188",
"_rev": "2-7d3a9f012b4e8c56ab1d2ef3",
"type": "order",
"customer_id": "user:42",
"items": [
{ "sku": "WIDGET-01", "qty": 3, "price": 9.99 },
{ "sku": "GADGET-07", "qty": 1, "price": 49.00 }
],
"total": 78.97,
"status": "pending",
"created_at": "2024-03-15T08:22:00Z",
"_attachments": {
"invoice.pdf": {
"content_type": "application/pdf",
"length": 48312,
"stub": true
}
}
}
Values can be any valid JSON type: strings, numbers, booleans, arrays, or nested objects. Binary data is stored as attachments under the reserved _attachments key. Special system documents — design documents (_design/) and local documents (_local/) — live in the same database namespace but are handled differently by the replication engine.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
