i using couchbase lite database project schemaless know, , happy 1 because solves issues, raise me 1 question related primary key contraints in nosql (document database).
as know schema database represented in tables, , these tables may or may not have primary/forgien key. example lets suppose have table called student has the primary key usn(university seat number), along other attributes, firstname, lastname, address, contactnumber, etc etc.
usn | firstname | lastname | address | contactnumber
2ba11cs409 | abc | mnq | bangalore | 1234567890
2ba11cs410 | xyz | pqr | mumbai | 1234567809
here table through error saying violation of primary key constraints (cannot added duplicate key) if tried add 2bs11cs409 value once again.
but case in document database, how identify unique value within document,
docid:123456789zxcv { usn : 2ba11cs409, firstname : abc, ....... ....... etc } i know each document has 1 unique id key indexed searching in database, created document same values above,
docid:zxcv123456789 { usn : 2ba11cs409, firstname : abc, last ....... etc } when try access 1 database usn, has return me 1 document, return me 2 document may identical or different.
i need know primary/unique key kind of concept in document database, exist in relational database. or can redirect me articles
thank you.
well, schema or no schema unique key constraints use index, advantage rdbs provide service you, in case of couchbase need yourself. have second collection, represents index. each time want insert in standard collection, check index first whether document usn want insert exists, if doesn't insert document normal collection. insert document index docid=usn , if want can insert reference docid of document inserted normal collection.
Comments
Post a Comment