레이블이 Database인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Database인 게시물을 표시합니다. 모든 게시물 표시

2015년 11월 30일 월요일

NoSQL Systems with CAP theorem

출처: http://blog.nahurst.com/visual-guide-to-nosql-systems



  • Consistency means that each client always has the same view of the data.
  • Availability means that all clients can always read and write.
  • Partition tolerance means that the system works well across physical network partitions.
According to the CAP Theorem, you can only pick two.

In addition to CAP configurations, another significant way data management systems vary is by the data model they use: relational, key-value, column-oriented, or document-oriented (there are others, but these are the main ones).
  • Relational systems are the databases we've been using for a while now. RDBMSs and systems that support ACIDity and joins are considered relational.
  • Key-value systems basically support get, put, and delete operations based on a primary key.
  • Column-oriented systems still use tables but have no joins (joins must be handled within your application). Obviously, they store data by column as opposed to traditional row-oriented databases. This makes aggregations much easier.
  • Document-oriented systems store structured "documents" such as JSON or XML but have no joins (joins must be handled within your application). It's very easy to map data from object-oriented software to these systems.
Now for the particulars of each CAP configuration and the systems that use each configuration:
Consistent, Available (CA) Systems have trouble with partitions and typically deal with it with replication. Examples of CA systems include:
  • Traditional RDBMSs like Postgres, MySQL, etc (relational)
  • Vertica (column-oriented)
  • Aster Data (relational)
  • Greenplum (relational)
Consistent, Partition-Tolerant (CP) Systems have trouble with availability while keeping data consistent across partitioned nodes. Examples of CP systems include:
Available, Partition-Tolerant (AP) Systems achieve "eventual consistency" through replication and verification. Examples of AP systems include:


2015년 6월 26일 금요일

Max. Size of a Data file (Oracle): ORA-01688

오류 사항

ORA-01688: unable to extend table <schema>.<table> partition <parts> by <number> in tablespace <tablespace> 


-------------------------------------------------------------------------------------------------------------
출처: https://community.oracle.com/thread/521373

Data files are not exactly unlimited in size, so the term "Unlimited" refers to the ceiling your datafile is able to reach, and it depends on the Oracle Block Size. To find the absolute maximum file size multiply block size by 4194303. This is the actual maximum size. You may want to read the Metalink Note:112011.1.

A datafile cannot be oversized, otherwise it could get corrupted. Let's say if your database is 8k blocks that means that one file can not exceed approximately 34GB (34,359,730,176 bytes) without having database corruption.

Sizing datafiles is a matter of manageability, it depends on your storage, the amount of space allocated in a single managed storage unit.

128G is the maximum datafile size in 10g, but considering the maximum number of datafiles a Database can have, it can make a database to potentially size 8E (exabytes = 8,388,608 T).

The maximum data file size is calculated by:
Maximum datafile size = db_block_size * maximum number of blocks

The maximum amount of data in an Oracle database is calculated by:
Maximum database size = maximum datafile size * maximum number of datafile

The maximum number of datafiles in Oracle9i and Oracle 10g Database is 65,536. However, the maximum number of blocks in a data file increase from 4,194,304 (4 million) blocks to 4,294,967,296 (4 billion) blocks.

The maximum amount of data for a 32K block size database is eight petabytes (8,192 Terabytes) in Oracle9i.

Maximum database size is 8Pb in Oracle9i & 10g (Small file Tablespaces).
Block Sz   Max Datafile Sz (Gb)   Max DB Sz (Tb)

--------   --------------------   --------------

   2,048                      8              512

   4,096                     16            1,024

   8,192                     32            2,048

  16,384                     64            4,096

  32,768                    128            8,192
 
The maximum database size is 8Eb in Oracle 10g (Big file tablespaces).
Block Sz   Max Datafile Sz (Gb)   Max DB Sz (Tb)

--------   --------------------   --------------

   2,048                  8,192          524,264

   4,096                 16,384        1,048,528

   8,192                 32,768        2,097,056

  16,384                 65,536        4,194,112

  32,768                131,072        8,388,224
 
 
 

해결 방안

SQL> ALTER TABLESPACE <tablespace_name> ADD DATAFILE
  2  <file_path> SIZE 10240M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED; 
 
 
 
 

2015년 6월 25일 목요일

Oracle Linux 7 기반 Oracle Database 11g R2 설치

Linux 기초 명령어 (RedHat 계열)



    - hostname 변경
      # vi /etc/hostname
      # vi /etc/sysconfig/network
      # vi /etc/hosts
      # service network restart
      # reboot

    - zip / unzip
      $ zip -r test.zip ./*
      $ unzip happy.zip
      $ unzip happy.zip -d ./target

    - tar.gz
      $ tar -czvf images.tar.gz ./test
      $ tar -xzvf images.tar.gz

    - software update
      # yum list updates
      # yum update –y 


Oracle Database 11g R2 installation


$ su -

# df -h

# usermod -g oinstall -G dba oracle
# useradd -g oinstall -G dba oracle
# passwd oracle

# /sbin/sysctl -p
# /sbin/sysctl -a

# mkdir -p /opt/app/
# chown -R oracle:oinstall /opt/app/
# chmod -R 775 /opt/app/

# su - oracle
$ export TMP=/tmp
$ export TMPDIR=$TMP

$ export ORACLE_BASE=/opt/app/oracle
$ export ORACLE_SID=orcl



After installation

# vi /etc/oratab
SID:ORACLE_HOME:{Y|N|W} ----> Y

# vi /etc/init.d/oracle
#!/bin/bash

# oracle: Start/Stop Oracle Database 11g R2
#
# chkconfig: 345 90 10
# description: The Oracle Database is an Object-Relational Database Management System.
#
# processname: oracle

. /etc/rc.d/init.d/functions

LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome
ORACLE_USER=oracle

case "$1" in
'start')
   if [ -f $LOCKFILE ]; then
      echo $0 already running.
      exit 1
   fi
   echo -n $"Starting Oracle Database:"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
   touch $LOCKFILE
   ;;
'stop')
   if [ ! -f $LOCKFILE ]; then
      echo $0 already stopping.
      exit 1
   fi
   echo -n $"Stopping Oracle Database:"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
   rm -f $LOCKFILE
   ;;
'restart')
   $0 stop
   $0 start
   ;;
'status')
   if [ -f $LOCKFILE ]; then
      echo $0 started.
      else
      echo $0 stopped.
   fi
   ;;
*)
   echo "Usage: $0 [start|stop|status]"
   exit 1
esac

exit 0



# chmod 755 /etc/init.d/oracle
# chkconfig --add oracle
# chkconfig oracle on

http://localhost:1158/em
$ emctl stop dbconsole
$ emctl config emkey -repos -sysman_pwd
$ emctl secure dbconsole -sysman_pwd
$ emctl start dbconsole
$ emctl config emkey -remove_from_repos -sysman_pwd


$ lsnrctl start
$ lsnrctl status
$ lsnrctl stop
$ netstat -anp | grep 1521 | grep LISTEN

$ sqlplus "/as sysdba"
SQL> startup
SQL> shutdown normal|immediate|abort



$ vi ~/.bash_profile
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/opt/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome
export ORACLE_HOME_LISTNER=$ORACLE_HOME/bin/lsnrctl
export ORACLE_SID=TMSRACDB
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export PATH=$ORACLE_HOME/bin:$PATH




Installed information


DB Global Name
SQL> SELECT * FROM props$ WHERE name='GLOBAL_DB_NAME';
SQL> SELECT * FROM global_name;


SQL> ALTER DATABASE RENAME GLOBAL_NAME TO <>;

SID
SQL> select name from v$database;
SQL> SELECT instance FROM v$thread;




re-installation


# rm -Rf /usr/local/bin/oraenv
# rm -Rf /usr/local/bin/coraenv
# rm -Rf /etc/oratab

# chkconfig oracle off
# chkconfig --del oracle
# rm -Rf /etc/init.d/oracle
# rm -Rf $ORACLE_HOME

$ unset ORACLE_HOME
$ unset TNS_ADMIN


기타

** tnsname.ora
- $ORACLE_HOME/network/admin
- 로컬컴퓨터가 원격 서버로 접속할 방법을 서술

** listener.ora
- $ORACLE_HOME/network/admin
- 오라클서버에서 리스너를 기동시킬 때 (즉, lsnrctl start) 사용하게 되는 환경 파일

$ sqlplus -S scott/tiger < /data/script/test.sql
(-S : uses silent mode)

MongoDB에 대한 8가지 오해와 진실

출처: http://cafe.naver.com/mongodatabase/1811


안녕하세요? MongoDB Master 주종면입니다.
2012년 초에 외국 기사에 MongoDB애 대한 부정적 기사가 올아왔어죠~
그리고, NoSQL & MongoDB 사용자들 사에 이슈가 많이 되었던 내용이기도 했구요..
아직도, 당시의 기사에 대한 질문을 하시는 분들이 간혹 걔시며 잘못된 오해로 인해 MongoDB 를 적절하게 사용하고 있지 못하는 문제점을 해소하기 위해 이 기사를 올리게 되었습니다.



1. MongoDB의 기본 설정상태로 빅 데이터에 대한 쓰기작업은 안전하지 않다.


 애플리케이션 레벨에서 드라이버를 통해  MongoD에 접속할 때 getLastError 함수에 의해 데이터 처리에 대한 성공 여부를 Check하게 되는데 이때 그 결과를 리턴 해 주는 레벨을 Safe 모드라고 하며 처리 결과를 돌려주지 않는 레벨을 Unsafe 모드라고 합니다. 기본 설정 모드는 Unsafe 모드인데 이것은 NoSQL의 대표적인 특징인 초당 몇 만 건의 빅 데이터를 빠르게 쓰기 하기 위함입니다.
만약, 기본 설정 모드를 Safe 모드로 설정하게 된다면 빅 데이터에 대한 쓰기 작업 시 매 건마다 처리 여부를 확인해야 하기 때문에 빠른 쓰기 작업을 수행할 수 없게 될 것 입니다.
만약, 데이터의 무결성이 보장되어야 하는 경우라면 사용자의 선택에 의해 safe 모드를 사용할 수 있으며 다만, 이것은 빠른 쓰기 성능을 지연하게 될 것 입니다.

<결론>

MongoDB Write Concern 정책과 빅 데이터를 위한 빠른 쓰기/읽기 솔루션에 대한 이해 부족으로 인한 잘못된 해석으로 판단됩니다..

2. MongoDB 운영 시 다양한 이유로 데이터가 날라가는 경우가 발생한다.


MongoDB 1.8 이전(2011) 버전에는 Journal 기능이 없어 Memory 영역에 대한Crash 발생하는 경우 백업 데이터가 존재하지 않기 때문에 데이터 유실이 발생하였습니다. 하지만, 이러한 문제를 개선하기 위해 이후 버전에서는 메모리 상에 입력, 수정, 삭제된 데이터는 실 시간으로 Journal 파일에 백업부터 되기 때문에 Memory Crash가 발생하더라도 Journal 파일을 통해 거의 모든 데이터에 대한 복구가 가능하며 최근에는 이러한 사례가 보고되고 있지 않습니다.

<결론>

MoggoDBNoSQL 영역에서 아직도 성장하는 기술 중에 하나이므로 몇몇 버그들이 발견되고 있지만 현재 대부분의 관계형 DB에서 발생하는 범주라고 판단됩니다. 1988년 당시 국내 모 신문 기사에는 일부 데이터 유실과 관련된 관계형 데이터베이스의 문제점에 대한 기사들을 종종 볼 수 있었는데 이러한 문제는 시간이 지나면서 자연스럽게 해소되었던 것처럼 현재 버전의 MongoDB에서도 발견되고 있지 않습니다.


3. 빅 데이터 환경에서 써야 할 데이터 양이 많으면 감당하지 못한다.


NoSQL의 대표적인 기술 중에 하나는 Memory Mapping 기술인데 이것은 충분한 시스템 메모리를 요구합니다.
하지만, 대부분의 사용자들은 관계형 데이터베이스 수준의 시스템 메모리 정도로 NoSQL을 운영하고 있으며 빅 데이터를 처리하고 있는 것이 현실입니다.
문제는 이러한 환경에서는 빅 데이터를 효과적으로 처리할 수 없을 뿐만 아니라 오히려 다양한 성능 지연 및 장애 현상을 유발시킬 수 도 있습니다.
관계형 DBMS의 경우에도 부적절한 메모리 할당으로 인한 성능 지연 및 장애가 발생하는 경우 서버 튜닝을 통해 문제 해결을 수행하고 있습니다.

<결론>

대부분의 사용자들은 기술적 기반과 아키텍처 구조가 다른 NoSQL RDBMS 관점에서 접근하고 이해하려는 경향들이 있습니다.  이러한 접근 방법으로는 NoSQL 기술을 제대로 이해하고 사용하는 것은 한계가 있을 수 밖에 없습니다.
** 원문에서는 Global Lock으로 인한 쓰기 성능에 대한 이슈를 강조하였는데    이 문제는 2.0 버전에서 Database Lock 매커니즘을 통해 대 부분 해소되었으며 2013 12월까지 Collection Lock 기능까지 제공하겠다고 발표하였으며 보다 향상된 성능이 기대됩니다.


4. 데이터 분산처리 시스템인 샤딩 환경에서 데이터를 불러올 때 적절한 샤딩이 제대로 작동하지 않을 때가 있다.


MongoDB를 사용하는 대부분의 사용자들은 샤딩 시스템을 구축하는 것 만으로 좋은 성능을 기대할 수 있다고 생각하는 경우들이 종종 있습니다.
하지만, 그렇지 않습니다. 우리나라에는 과유불급이라는 속담이 있습니다.
어떤 좋은 기능이라도 이것을 구축하려는 환경에 적합한지, 구축 시 고려해야 할 사항이 무엇인지, 구축 후 관리 사항에 대한 정확한 기술적 접근과 이해를 바탕으로 구축 여부를 결정하는 것이 올바른 접근 방법입니다.
샤딩이 정상적으로 잘 작동되기 위해서는 몇 가지 전제 조건이 필요합니다.
먼저, 빠른 쓰기 작업에 있어서 Chunk Size Shard Key를 적절하게 설계해야 하는데 대부분 사용자들은 단순히 데이터 양적인 측면에서의 분산 저장 정도로 생각하여 단순 설계하기 때문에 결국 좋은 성능이 보장되지 않는 것입니다.
또한, Peak Time에 과도한 마이그레이션이 발생하는 경우 데이터 읽기 작업이 발생한다면 빠른 읽기 및 쓰기 성능이 보장되지 못할 것 입니다.

<결론>

샤딩 및 복제 기술과 DBMS 운영 기술에 대한 이해 부족으로 잘못 운영함으로서
발생했던 문제점으로 판단됩니다, .


5. 데이터 삭제 또는 변경 했을 때 단편화 문제가 발생하여 데이터 처리에 필요 이상의 메모리를 사용합니다.


단편화(Fragmentation) 현상은 모든 파일 시스템 그리고 RDB에서 발생하는 문제점이며 MongoDB 만의 문제점은 아닙니다. 또한, 단편화가 발생한다고 시스템의 메모리룰 사용하는 것은 아니기 때문에 반드시 과 부하가 발생하지는 않습니다.

<결론>

단편화 현상에 대한 이해 부족과 MongoDB 메모리 구조 및 운영 메커니즘애 대한 이해 부족으로 인해 MongoDB 아키테처 구조의 문제점으로 잘못 이해하고 있는 것으로 생각됩니다.

** 원문에서는 mongos 프로세스가 가끔 shutdown 되는 문제에 대한 이슈를 강조하였는데 일반적으로 mongos 프로세스와 유사한 구조는 기존의 관계형 DB 또는 많은 애플리케이션에서도 발생하는 문제점이기도 합니다.
이러한 문제에 대한 원인은 대부분 시스템 메모리 영역과의 Crash에 의해 발생하게 되는데 이 문제점에 대한 대응은 Crash에 대비하여 여러 개의 mongos를 활성화하여 FailOver에 대비해야 합니다.    


6. 몽고DB 1.8 이후 버전에서 문제가 해결되었지만 데이터 셋을 전부 날리는 경향이.있습니다.


2) 질문 내용에 대한 답변과 동일함.


7. 몽고 DB에서 발견된 버그가 빨리 해결되지 않는다.


미국의 공인된 평가 기관인 PerfectMarket사의 2011년 발표에 의하면 조사 분석된 NoSQL 제품 중 MongoDB는 버그에 대한 빠른 패치 제공이 이루어지고 있고 커뮤니티에 대한 지원이 가장 좋다는 평가 결과가 있습니다.

2.2 (2012년 초) 2.3 (2012년 말) 2.4 (2013 3) 2.5 (201311)

실제 원문에서 말하려고 했던 것은 문제점에 대한 패치를 즉시 제공하지 않고 다음 릴리즈 버전에서 제공한다는 점을 어필했던 것으로 보입니다.
1.8 버전이 발표되었던 시점에 미국 Funding 마켓에서 NoSQL의 비중에 낮았다면 2011년 이후 급속도로 Funding 투자의 활성화로 자금 유입과 함께 보다 빠른 버그에 대한 대응 및 패치가 제공되고 있는 것으로 판단됩니다.


8. 데이터의 안전한 저장을 위한 복제 시스템이 필요 이상의 서버를 차지한다.


Replication은 빅 데이터를 처리할 때 발생하는 데이터 유실을 방지하기 위한 최후의 수단입니다.
몽고 DB ReplicaSets을 통해 여러 대의 서버에 데이터를 복제할 수 있는데 이것은 사용자의 선택이지 필수 조건이 아닙니다. 적절한 시스템 설계를 통해 구현하지 않고 오픈 소스의 장점 만이 부각되어 부 적절하게 구축되는 경우에 해당합니다. 이러한 무절제한 복제가 서버 부하를 유발시키는 것은 당연하며 이것은 모든 NoSQL 뿐만 아니라 관계형 DB에서도 발생합니다.
이 문제를 해결할 수 있는 방법은 MongoDB에서 제공하는 다양한 백업/복구 솔루션과 함께 최소한의 서버로 복제 시스템을 구축하는 것입니다.

<결론>

Replication 시스템 및 운영 메커니즘애 대한 이해 부족으로 판단됩니다.



지금까지 설명된 8가지 사항은 현재 국내 MongoDB 시장에서 사용자 간에 회자되고 있는 MongoDB의 불편한 오해와 진실에 대한 설명이었습니다..
관계형 데이터베이스가 무려 40년이라는 세월 동안 꾸준하게 발전하며 평가 받아온 성숙된 기술이라면 MongoDB는 이제 8년 된 성장하고 있는 기술입니다.
MongoDB의 초기 버전에서 발생했던 몇 가지 문제점들은 상위 버전으로 업그레이드 되면서 많은 발전을 이루어 내었고 이제 안정화 단계로 접어들고 있는 것이 현실입니다. 어떠한 기술이든 초기 버전부터 완벽한 기술과 기능을 제공하는 제품은 없습니다. 많은 사용자의 관심과 지속적인 투자를 통해 사용자의 바램을 충족할 수 있는 기술로 발전하는 것 입니다. 이제 MongoDB는  NoSQL 분야에서 선택될 수 밖에 없는 기술로 평가 받고 있고 사용자의 관심을 끌고 있습니다. 앞서 소개 드린 MongoDB의 불편한 오해를 말끔히 털어내시고 여러분의 비즈니스 분야에 MongoDB를 적극적으로 활용해 보시기를 권장합니다.

감사합니다.

MongoDB와 Key-Value DB 그리고 RDB 간 기능 비교

출처: http://cafe.naver.com/mongodatabase/2264


안냥하세요? MongoDB Master 주종면입니다.
다음은 MongoDB와 Key-Value DB 그리고  RDB 간에 기능 비교 도표입니다.
참고하십시오. (www.mongodb.org)
감사합니다.




Document-Oriented Database

Document-oriented database
From Wikipedia, the free encyclopedia

This article is about the software type. For usage/deployment instances, see Full text database.

A document-oriented database is a computer program designed for storing, retrieving, and managing document-oriented information, also known as semi-structured data. Document-oriented databases are one of the main categories of NoSQL databases and the popularity of the term "document-oriented database" (or "document store") has grown[1] with the use of the term NoSQL itself. In contrast to relational databases and their notion of "Relation", i.e., a tuple (or row) of related strong-typed data items, these systems are designed around an abstract notion of a "document".
Document-oriented databases are inherently a subclass of the key-value store, another NoSQL database concept. The difference lies in the way the data is processed; in a key-value store the data is considered to be inherently opaque to the database, whereas a document-oriented system relies on internal structure in order to extract metadata that the database engine uses for further optimization. Although the difference is often moot due to tools in the systems, and the two can often be interchanged in operation, conceptually the document-store is designed to offer a richer experience with modern programming techniques.
XML databases are a specific subclass of document-oriented databases.

Contents

Documents
The central concept of a document-oriented database are the documents, which is used in usual English sense of a group of data that encodes some sort of user-readable information. This contrasts with the value in the key-value store, which is assumed to be opaque data. The basic concept that makes a database document-oriented as opposed to key-value is the idea that the documents include internal structure that the database engine can use to further automate the storage and provide more value.
To understand the difference, consider this text document:

 Bob Smith
 123 Back St.
 Boys, AR, 32225
 US

Although it is clear to the reader that this document contains the address for a contact, there is no information within the document that indicates that, nor information on what the individual fields represent. This file could be stored in a key-value store, but the semantic content that this is an address may be lost, and the database has no way to know how to optimize or index this data by itself. For instance, there is no way for the database to know that "AR" is the state, it is simply a piece of data in a string that also includes the city and zip code. Even the format might change, one might have a PO Box or suite number that adds another line to the address, which places the state information in the 4th line instead of 3rd. Without additional information, parsing this data can be complex.
Now consider the same document marked up in pseudo-XML:
<address>
   <firstname>Bob</firstname>
   <lastname>Smith</lastname>
   <street1>123 Back St.</street1>
   <city>Boys</city>
   <state>AR</state>
   <zip>32225</zip>
   <country>US</country>
 </address>

In this case, the document includes both data and the metadata explaining each of the fields. A key-value store receiving this document would simply store it. In the case of a document-store, the system understands that address documents may have a country field, allowing the programmer to "find all the addresses where the state is 'AR'". Additionally, the programmer can provide hints based on the document type or fields within it, for instance, they may tell the engine to place all address documents in a separate physical store, or to make an index on the state field for performance reasons. All of this can be done in a key-value store as well, and the difference lies primarily in how much programming effort is needed to add these indexes and other features; in a document-store this is normally almost entirely automated.
Now consider a slightly more complex example, one that is more realistic:
 <contact>
   <firstname>Bob</firstname>
   <lastname>Smith</lastname>
   <email type=Home>bob.smith@gmaile.com</email>
   <phone type=Cell>(123) 456-7890</phone>
   <phone type=Work>(890) 765-4321</phone>
   <address>
     <type>Home</type>
     <street1>123 Back St.</street1>
     <city>Boys</city>
     <state>AR</state>
     <zip>32225</zip>
     <country>US</country>
   </address>
 </contact>

With similar hints, the document store will know that this is a contact entry and allow searches for things like "find all my contacts with a work phone number but no work email".
Storing this sort of data in a relational database can be complex. First, the programmer must create separate tables for each of the data types, in this case CONTACTS, EMAILS, PHONES and ADDRESSES. To insert the data into the store, five commands are needed, insert the contact into CONTACTS, insert the email, two inserts for the phone numbers, and finally the address. Since the database does not directly understand any of the data, queries like "find all the contacts in Arizona" require one to look in the ADDRESSES table, not the CONTACTS, and then reconstruct the original object by JOINing on the associated tables. Some systems, the object-oriented databases, address by allowing the programmer to provide additional information about the relationships between the data, but this is driven by the programmer, not the data itself. If one were to add a new data type to this document, say the <image>, a document-oriented database would immediately be able to "find all the contacts with images", while even an object-oriented system would require additional setup and definitions to store the data.
The usefulness of this sort of introspection of the data is not lost on the designers of other database systems. Many key-value stores include some or all of the functionality of dedicated from the start document stores, and a number of relational databases, notably PostgreSQL and Informix, have added functionality to make these sorts of operations possible. It is not the ability to provide these functions that define the document-orientation, but the ease with which these functions can be implemented and used; a document-oriented database is designed from the start to work with complex documents, and will (hopefully) make it easier to access this functionality than a system where this was added after the fact.
Documents inside a document-oriented database are similar, in some ways, to records or rows in relational databases, but they have vastly more internal structure (the extent the database itself is aware of that structure, and can use it, varies). Documents, particularly in XML, TeX, and other high-end formats, do adhere to a formal schema; but many documents do not, or if they do, the schema is not explicit. For example, the following is a document:
<Article>
   <Author>
       <FirstName>Bob</FirstName>
       <Surname>Smith</Surname>
   </Author>
   <Abstract>This paper concerns....</Abstract>
   <Section n="1"><Title>Introduction</Title>
       <Para>...
   </Section>
 </Article>

A second document, even of the same genre and schema, may have a far different number and arrangement of sections, paragraphs, and the like; it may have multiple co-authors; it may have much other metadata such as copyright or publication information, bibliographic references to other documents (in the same or other databases, or in no database at all), and so on.
Two such documents typically share many structural elements with one another, but each may also have elements the other does not. Unlike a relational database where every record contains the identical sequence of fields (a few of which may be empty or hold missing value indicators), document structures generally allow for an unbounded number of hierarchically-organized components, with extensive repetition. It would be absurd, for example, to design a database with table for "sections," that tried to provide as many fields as the number of paragraphs in the longest section one will ever see (not to mention the many other kinds of document components that appear within sections). Even if one did, naming fields in a relation something like "p1", "p2",... does not, so far as the database is concerned, indicate that those fields have anything to do with one another, or belong in a certain meaningful order. In order to avoid confusion with the quite different notion of database "fields", document databases may refer to the parts of documents as "components" or "elements".
Practically any "document" containing metadata can be managed in this fashion, and common examples include XML, YAML, JSON, and BSON. Some document-oriented databases include functionality to help map data lacking clearly defined metadata. For instance, many engines include functionality to index PDF or TeX documents, or may include predefined document formats that are in turn based on XML, like MathML, JATS or DocBook. Some allow documents to be mapped onto a more suitable format using a schema language such as DTD, XSD, Relax NG, or Schematron. Others may include tools to map enterprise data, like column-delimited text files, into formats that can be read more easily by the database engine. Still others take the opposite route, and are dedicated to one type of data format, JSON. JSON is widely used in online programming for interactive web pages and mobile apps, and a niche has appeared for document stores dedicated to efficiently handling them.
Some of the most popular Web sites are document databases. The many collections of articles at pubmed.gov or major journal publishers; Wikipedia and its kin; and even search engines (though many of those store links to indexed documents, rather than the full documents themselves).

Keys and retrieval
Documents may be addressed in the database via a unique key that represents that document. This key is often a simple string, a URI, or a path. The key can be used to retrieve the document from the database. Typically, the database retains an index on the key to speed up document retrieval. The most primitive document databases may do little more than that. However, modern document-oriented databases provide far more, because they extract and index all kinds of metadata, and usually also the entire data content, of the documents. Such databases offer a query language that allows the user to retrieve documents based on their content. For example, you may want to retrieve all the documents whose date falls within some range, that contains a citation to another document, etc.. The set of query APIs or query language features available, as well as the expected performance of the queries, varies significantly from one implementation to the next.

Organization
Implementations offer a variety of ways of organizing documents, including notions of:
  • Collections
  • Tags
  • Non-visible Metadata
  • Directory hierarchies
  • Buckets

Comparison with relational databases
In a relational database, data is first categorized into a number of predefined types, and tables are created to hold individual entries, or records, of each type. The tables define the data within each record's fields, meaning that every record in the table has the same overall form. The administrator also defines the relations between the tables, and selects certain fields that they believe will be most commonly used for searching and defines indexes on them. A key concept in the relational design is that any data that may be repeated is placed in its own table, and if these instances are related to each other, a field is selected to group them together, the foreign key.
For example, an address book application will generally need to store the contact name, an optional image, one or more phone numbers, one or more mailing addresses, and one or more email addresses. In a canonical relational database solution, tables would be created for each of these records with predefined fields for each bit of data; the CONTACT table might include FIRST_NAME, LAST_NAME and IMAGE fields, while the PHONE_NUMBER table might include COUNTRY_CODE, AREA_CODE, PHONE_NUMBER and TYPE (home, work, etc). The PHONE_NUMBER table also contains a foreign key field, "CONTACT_ID", which holds a the unique ID number assigned to the contact when it was created. In order to recreate the original contact, the system has to search through all of the tables and collect the information back together using joins.
In contrast, in a document-oriented database there may be no internal structure that maps directly onto the concept of a table, and the fields and relations generally don't exist as predefined concepts. Instead, all of the data for an object is placed in a single document, and stored in the database as a single entry. In the address book example, the document would contain the contact's name, image and any contact info, all in a single record. That entry is accessed through a key, some unique bit of data, which allows the database to retrieve and return the document to the application. No additional work is needed to retrieve the related data, all of this is returned in a single object.
A key difference between the document-oriented and relational models is that the data formats are not predefined in the document case. In most cases, any sort of document can be stored in any database, and those documents can change in type and form at any time. If one wishes to add a COUNTRY_FLAG to a CONTACT, simply add this field to new documents as they are inserted, this will have no effect on the database or the existing documents already stored, they simply won't have this field. This indicates an advantage of the document-based model; optional fields are truly optional, a contact that does not include a mailing address simply does not have a mailing address, there is no need to check another table to see if there are entries.
To aid retrieval of information from the database, document-oriented systems generally allow the administrator to provide hints to the database to look for certain types of information. In the address book example, the design might add hints for the first and last name fields. When the document is inserted into the database (or later modified), the database engine looks for these bits of information and indexes them, in the same fashion as the relational model. Additionally, most document-oriented databases allow documents to have a type associated with them, like "address book entry", which allows the programmer to retrieve related types of information, like "all the address book entries". This provides functionality similar to a table, but separates the concept (categories of data) from its physical implementation (tables).
All of this is predicated on the ability of the database engine to examine the data in the document and extract fields from the formatting, its metadata. This is easy in the case of, for example, an XML document or HTML page, where markup tags clearly identify various bits of data. Document-oriented databases may include functionally to automatically extract this sort of information from a variety of document types, even those that were not originally designed for easy access in this manner. In other cases the programmer has to provide this information using their own code. In contrast, a relational database relies on the programmer to handle all of these tasks, breaking down the document into fields and providing those to the database engine, which may require separate instructions if the data spans tables.
Document-oriented databases normally map more cleanly onto existing programming concepts, like object-oriented programming (OOP). OOP systems have a structure somewhere between the relational and document models; they have predefined fields but they may be empty, they have a defined structure but that may change, they have related data store in other objects, but they may be optional, and collections of other data are directly linked to the "master" object, there is no need to look in other collections to gather up related information. Generally, any object that can be archived to a document can be stored directly in the database and directly retrieved. Most modern OOP systems include archiving systems as a basic feature.
The relational model stores each part of the object as a separate concept and has to split out this information on storage and recombine it on retrieval. This leads to a problem known as object-relational impedance mismatch, which requires considerable effort to overcome. Object-relational mapping systems, which solve these problems, are often complex and have a considerable performance overhead. This problem simply doesn't exist in a document-oriented system, and more generally, in NoSQL systems as a whole.

Implementations
Name
Publisher
License
Language
Notes
RESTful API
C, C++ &amp; Javascript
A distributed multi model, high-performance document store and graph database.
Yes [2]
Support for XML, JSON and binary formats; client-/server based architecture; concurrent structural and full-text searches and updates; REST APIs.
Yes
JSON over HTTP
Yes
Erlang, Java, Scala, and C
Distributed database service based on BigCouch, the company's open source fork of the Apache-backed CouchDB project.
Yes
Free license
Distributed XML and JSON database server with secure high-performance ACID-compliant transactions; built-in full text search; database as a service[3]
Yes
Erlang and C
Distributed NoSQL Document Database.
Yes [4]
JSON over REST/HTTP with Multi-Version Concurrency Control and limited ACID properties. Uses map and reduce for views and queries.[5]
Yes [6]
Dotissi SRL
Commercial
C# - .NET, Windows Store, Windows Phone, Xamarin.iOS, Xamarin.Android, Unity3D, Mono; Java - Android
Privacy aware cloud-mobile database, with client libraries for Windows Store, Windows Phone, Xamarin Android, Xamarin iOS, Android, Unity3D (iOS, Android, Windows Store, Windows Phone)
Yes
XML over REST/HTTP, WebDAV, Lucene Fulltext search, validation, versioning, clustering, triggers, URL rewriting, collections, ACLS, XQuery Update
Yes [7]
FleetDB
A JSON-based schema-free database optimized for agile development.
(unknown)
IBM
Various (Compatible with MongoDB API)
RDBMS with JSON, replication, sharding and ACID compliance
(unknown)
Inquire
unknown
In the mid-80's this was the dominant document-oriented commercial database, widely successful. The company seems to have gone out of business in 2005.
(unknown)
IBM
LotusScript, Java, Lotus @Formula

(unknown)
MarkLogic Corporation
Distributed document-oriented database with Multi-Version Concurrency Control, integrated Full text search and ACID-compliant transaction semantics
Yes
MongoDB, Inc
GNU AGPL v3.0 for the DBMS, Apache 2 License for the client drivers[8]
Document database with replication and sharding
Optional [9]
MUMPS Database[10]

Commonly used in health applications.
(unknown)
JSON over HTTP
Yes
Distributed document-oriented database with integrated Full text search
Yes

Yes

Key-value store supporting lists and sets with binary-safe protocol
(unknown)

GNU APGL for the DBMS, Apache 2 License for the client drivers

(unknown)
Rocket Software

UniData, UniVerse
Yes (Beta)
Distributed, real-time database featuring cell-level security and massive scalability.
Yes
Secure web-based data collection and management platform tailored for research.
(Unknown)


XML database implementations
Further information: XML database
Most XML databases are document-oriented databases.