Berkeley DB Reference Guide:
Access Methods

PrevRefNext

Opening multiple databases in a single file

Applications may create multiple databases within a single physical file. This is useful when the databases are both numerous and reasonably small, in order to avoid creating a large number of underlying files, or when it is desirable to include secondary index databases in the same file as the primary index database. Multiple databases are an administrative convenience and using them is unlikely to effect database performance. To open or create a file that will include more than a single database, specify a database name when calling the DB->open method.

(애플리케이션은 물리적인 단일 파일에 멀티 디비를 생성할 것이다.이런식의 디비생성은 디비들이 다수이고 아주 크기가 작을때 여러파일이 생성되는것을 피하기 위한 좋은 방법이고 프라이머리 인덱스 디비파일에 세컨더리 인덱스디비를 포함시키는 이상적인 방법이다.멀티플 디비는 관리가 편리하고 디비 퍼포먼스에 영향을 주지 않는다.여러개의 디비를 포함하는 파일을 열거나 생성하기 위해서는 DB->open를 호출할때 디비이름을 설정해야 한다.

 

Physical files do not need to be comprised of a single type of database, and databases in a file may be of any mixture of types, except for Queue databases. Queue databases must be created one per file and cannot share a file with any other database type. There is no limit on the number of databases that may be created in a single file other than the standard Berkeley DB file size and disk space limitations.

(물리적 파일은 단일 타입의 디비일 필요는 없고 Queue를 제외한 여러타입의 복합적구성일 수 있다.Queue는 단일파일로 생성이 되야하고 다른 타입이 이 파일안에 존재해서는 안된다.단일파일에 존재하는 디비의 수는 제한이 없다.)

 

It is an error to attempt to open a second database in a file that was not initially created using a database name, that is, the file must initially be specified as capable of containing multiple databases for a second database to be created in it.

(디비이름으로 초기 생성되지 않았던 디비를 오픈하는것은 에러를 발생시킨다.즉 여러 디비를 포함하는 파일은 초기에 두번째 디비를 생성해야 한다.)

 

It is not an error to open a file that contains multiple databases without specifying a database name, however the database type should be specified as DB_UNKNOWN and the database must be opened read-only. The handle that is returned from such a call is a handle on a database whose key values are the names of the databases stored in the database file and whose data values are opaque objects. No keys or data values may be modified or stored using this database handle.

(여러디비를 갖는 파일을 디비이름없이 오픈하는 것은 에러가 아니다.그러나 디비타입은 DB_UNKNOWN로 설정되어야 하고 read-only로 열려야 한다.리턴되는 핸들은 키값이 디비이름이고 데이터값이 불분명한 오브젝트인 디비에 대한 핸들이다.이키로 어떤 키나 데이타값도 변경되거나 저장되지 않는다.)

 

Storing multiple databases in a single file is identical to storing each database in a separate file with the exception of some configuration information and the likely need for locking and a shared underlying memory pool.

(단일파일에 여러디비를 저장하는 것은 약간의 설정정보를 제외하고는 개별파일에 저장하는것과 동일하고 메모리풀과 락을 필요로 할 수 있다.)

 

There are four types of configuration information which must be specified consistently for all databases in a file, rather than differing on a per-database basis. They are: byte order, checksum and encryption behavior, and page size. When creating additional databases in a file, any of these configuration values specified must be consistent with the existing databases in the file or an error will be returned.

(단일파일의 .(단일 디비단위가 보다는)모든 디비에 대해 일관되게 적용어야 하는 4가지 타입의 설정정보가 있다.이것은 바이트오더,체크섬,암호화동작,페이지크기설정이다.파일에 추가적인 디비를 생성할때 이 설정정보가 기존의 디비들과 같아야 하고 그렇지 않으면 에러를 발생한다.)

 

An additional difference is how locking and the underlying memory pool services must to be configured. As an example, consider two databases instantiated in two different physical files. If access to each separate database is single-threaded, there is no reason to perform any locking of any kind, and the two databases may be read and written simultaneously. Further, there would be no requirement to create a shared database environment in which to open the databases.

(추가적으로 다른점은 락에 대한 방법과 메모리풀서비스에 대한 방법이 설정되어야 한다는 점이다.예를들어 두개의 물리적인 파일에 각각 디비가 있다고 할때 만약 싱글쓰레드로 각 디비를 접근한다면 락이 필요없고 두 디비는 동시에 읽거나 쓸수있다.또한 디비열리때 공유된 디비환경이(역자주:위의 4개설정)이 필요없다.)

 

Because multiple databases in a file exist in a single physical file, opening two databases in the same file requires locking be enabled (unless access to the databases is known to be single-threaded, that is, only one of the databases is ever read or written at a time). As the locks for the two databases can only conflict during page allocation, this additional locking is unlikely to effect performance.

(단일파일에 여러디비가 존재하기때문에 같은 파일에서 두개의 디비를 오픈하는것은 싱글쓰레드가 아닌이상 락이필요하다.두 디비에 대한 락은 페이지할당시에 오직 충돌될수 있고 성능에는 영향을 주지 않는다.)

 

Also, because multiple databases in a file exist in a single physical file, opening two databases in the same file requires the databases share an underlying memory pool so that per-physical-file information common between the two databases is updated correctly.

(또한 단일파일에 여러디비가 존재하기 때문에 두개의 디비를 오픈하는것은 디비의 메모리풀 공유가 필요하게 되고 두파일사이의 일반적인 물리적파일당 정보가 업데이트되게 된다.)

 

In summary, programmers writing applications that open multiple databases in a single file will almost certainly need to create a shared database environment in the application as well. For more information on database environments, see Database environment introduction.

(요약해서 말하면,단일파일에 멀티디비를 사용하는 프로그래머는 공유된 디비환경의 생성이 필요하게 된다.자세한 정보는 Database environment introduction.참조)

 


PrevRefNext

Copyright (c) 1996-2003 Sleepycat Software, Inc. - All rights reserved.