2016-10-12 1 views
1

현재 내 Java 응용 프로그램을위한 임베디드 nosql 데이터베이스를 찾으려고합니다. 내 현재 접근 couchbase 라이트 자바를 사용하고 있습니다. 다음 예제를 실행하고 db.sqlite3 파일을 생성했습니다.couchbase lite는 실제로 no sql 데이터베이스가 없습니까?

  public class Main { 
       public static void main(String[] args) { 
        // Enable logging 
        Logger log = Logger.getLogger("app1"); 
        log.setLevel(Level.ALL); 
        JavaContext context = new JavaContext(); 
      // Create a manager 
        Manager manager = null; 
        try { 
         manager = new Manager(context, Manager.DEFAULT_OPTIONS); 
        } catch (IOException e) { 
         e.printStackTrace(); 
        } 
      // Create or open the database named app 
        Database database = null; 
        try { 
         database = manager.getDatabase("app1"); 
        } catch (CouchbaseLiteException e) { 
         e.printStackTrace(); 
        } 
      // The properties that will be saved on the document 
        Map<String, Object> properties = new HashMap<String, Object>(); 
        properties.put("title", "Couchbase Mobile"); 
        properties.put("sdk", "Java"); 
      // Create a new document 
        Document document = database.createDocument(); 
      // Save the document to the database 
        try { 
         document.putProperties(properties); 
        } catch (CouchbaseLiteException e) { 
         e.printStackTrace(); 
        } 
      // Log the document ID (generated by the database) 
      // and properties 
        log.info(String.format("Document ID :: %s", document.getId())); 
        log.info(String.format("Learning %s with %s", (String) document.getProperty("title"), (String) document.getProperty("sdk"))); 
        System.out.println(document.toString()); 
       } 
      } 

그래서 여기에 nosql 데이터베이스가 사용됩니까?

+0

예, Couchbase는 [공식 사이트] (http://www.couchbase.com/)에서 찾을 수있는 다중 모델 NoSQL 문서 지향 데이터베이스입니다. – DimaSan

+0

문서의 couchbase 라이트 지속성 메커니즘은 .sqlite3입니다. 나를 데이터베이스 파일의 관계형 모델이라고 혼동하게 만드는 것은 무엇입니까? 여기서 나를 깨우칠 수 있니? – user3014595

+0

NoSQL은 "Not SQL"의 약자입니다. – DimaSan

답변

2

물론입니다. 의견은 대부분 이미이 답변을합니다.

Couchbase Lite에는 스키마가 필요하지 않습니다. JSON 문서로 데이터를 저장합니다 (코드 샘플에 설명 된대로). 현재는 색인 생성 및 쿼리를 위해 map/reduce를 사용합니다. 완벽한 기능의 임베디드 NoSQL 데이터베이스입니다.

코딩 관점에서 볼 때 코드가 어떻게 구현되는지는 관련이 없습니다. 공개 API 외에는 알 필요도없고 의지 할 필요도 없습니다.

포인트를 만들기 위해 ForestDB를 사용할 수있는 Couchbase Lite 구현이 있습니다. ForestDB는 현재 SQLite보다 덜 성숙한 것으로 간주되므로 기본값이 아닙니다.

하나의 버전에서 SQLite를 사용하는 방법과 같은 구현 세부 정보에 관심이 있으시면이 코드를 살펴 보시기 바랍니다. 다양한 저장소 아래에서 찾을 수 있습니다 https://github.com/couchbase