2016년 12월 17일 토요일

Record ID

Tags

Record ID

이제 여러분은 OrientDB에서 데이터를 어떻게 클래스로 모델링 할 것인가에 대해 이해하며 그러한 클러스 내의 데이터를 구성하는 클러스터가 어떻게 구성하는지 이해했을 것이고, 레코드들이 물리적으로 어떻게 저장되고 검색되는지 이야기 할 수 있을 것입니다. 이번 섹션에서는 아래와 같은 것을 배울 것입니다.
  • 각 레코드들이 데이터베이스 내에서 고유한 레코드가 되는가
  • OrientDB에서는 얼마나 많은 데이터를 관리할 수 있는가(수천조)
  • console과 studio에서 Record ID를 이용해 데이터베이스의 레코드를 직접적으로 어떻게 접근할 수 있는가

OrientDB에서 각 레코드는 RecordID 혹은 RID라고 불리는 자신에게 할당된 고유의 ID를 가지고 있다. RID는 두 부분으로 구성된다.
#<cluster-id>:<cluster-position>즉
  • <cluster-id> 클러스터 ID
  • <cluster-position> 클러스터내에서 데이터의 위치
Each database can have a maximum of 32,767 clusters, or 215 - 1. Each cluster can handle up to 9,223,372,036,780,000 records, or 263, namely 9,223,372 billion records.
각 데이터는 최대 32,767개의 클러스터를 가질 수 있으며, 각 클러스터는 9,223조 3,720 억개의 record를 가질 수 있다.
한 데이터베이스의 최대 레코드량은 하드웨어 제약으로 인해 2^78개이지만, OrientDB는 그렇게 많은 수의 레코드를 테스트해보지 않았다. 그러나 수십억 레코드 범위에서 OrientDB를 사용하는 사용자들이 있다.

Record 불러오기

각 레코드는 Record ID를 가지고 있는데, 그것은 database내에서 물리적 위치를 알려준다. 이는, 여러분이 RID로 record를 불러올 때, 다른 조건으로 불러올 때보다 매우 빠르다는 것을 의미한다.
document db나 관계형 db에서 많은 데이터를 가질수록, database의 응답은 느려진다. OrientDB는 record를 가리키는 물리적 링크로 관계를 처리한다. edge가 생성될 때, 관계가 할당되며, 그래서 RID로 찾는 것은 O(1)시간 복잡도가 소요된다. 이는, 매번 O(log N)의 시간 복잡도를 갖는 관계형 데이터베이스와 비교된다. OrientDB에서는 데이터의 양이 탐색 시간에 영향을 미치지 않는다. 레코드가 한 개이건, 수천억이건, 탐색 시간은 계속 상수 시간이다. 빅데이터 시대에 이것은 매우 중요한 특징이다.

콘솔로 불러오기

레코드를 불러오기 위해서는 LOAD RECORD 명령을 이용하라.
orientdb> LOAD RECORD #34:0

DOCUMENT @class:Company @rid:#34:0 @version:2
+----+-----------+---------------------+
|#   |NAME       |VALUE                |
+----+-----------+---------------------+
|0   |id         |4                    |
|1   |created    |2016-09-01 00:00:00  |
|2   |name       |Microsoft4           |
|3   |salary2    |0.0                  |
|4   |checkpoint |true                 |
|5   |initialized|false                |
|6   |salary     |0.0                  |
|7   |addresses  |[NOT LOADED: #31:0]  |
|8   |employees  |100004               |
+----+-----------+---------------------+
LOAD RECORD 명령은 이 레코드에 대한 여러 유용한 정보를 반환한다. 
  • 이 레코드는 document이다. The record is a document. OrientDB supports different types of records, but document is the only type covered in this chapter.
  • It belongs to the Company class.
  • Its current version is 2. OrientDB uses an MVCC system. Every time you update a record, its version increments by one.
  • We have different field types:
    • floats for salary and salary2
    • integers for employees and id
    • string for name
    • booleans for initialized and checkpoint
    • date-time for created.
  • The field addresses has been NOT LOADED. It is also a LINK to another record, #31:0. This is a relationship. For more information on this concept, see Relationships.

Studio Load

OrientDB studio does not support the LOAD RECORD command. You will use SQL syntax in order to retrieve the a record by record ID when using Studio. We haven't gotten to OrientDB's SQL yet but for now you should just know that OrientDB does support it's own flavor of SQL. In it you do not have to you the * to project all columns of a record.
To do a direct look-up by Record ID we simply go to the browser window in Studio and type the following into the query editor:
select from #34:0
Then press the green 'run' button, to see the record you selected.
This code tells OrientDB to project all attributes and values of the record whose ID is passed in.
selectFromRecordID


EmoticonEmoticon

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:o
:>)
(o)
:p
:-?
(p)
:-s
8-)
:-t
:-b
b-(
(y)
x-)
(h)