the definitive guide to berkeley db xml

415 465 0
the definitive guide to berkeley db xml

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

CYAN MAGENTA YELLOW BLACK PANTONE 123 CV this print for content only—size & color not accurate 7" x 9-1/4" / CASEBOUND / MALLOY (0.8125 INCH BULK 416 pages 50# Thor) THE EXPERT’S VOICE ® IN OPEN SOURCE Danny Brian The Definitive Guide to Berkeley DB XML Simplify your storage, processing, and retrieval of data with embedded XML databases. BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® The Definitive Guide to Berkeley DB XML Dear Reader, Too often, form follows function—far too often when form is data and function is code. Code was created for data, not data for code. Useful data is valuable and interesting, meaningful outside of code or applications that operate upon it. We spend a lot of time and resources on getting data into the form appropriate for the function: tables for individual pieces of data, tables to map between tables, tables to express hierarchy, meta-table about tables… XML is attractive for its simplicity, flexibility, and ubiquity. This is already realized in the exchange of data: HTML, RSS feeds, RPC/SOAP, and thousands of proprietary dialects belong to the XML family. XML is easily read, under- stood, maintained, and manipulated with hundreds of compatible tools. Still, most served data is stored in relational databases, converted to and from XML at request or dump time. So why aren’t we storing data in XML to begin with? Two reasons. First, we need to index and execute complex queries on the data. And second, we want to log changes and maintain transactional data integrity. We can’t do that with just XML. Can we? Enter BDB XML, built atop Berkeley DB, the most deployed database on Earth. Within minutes of reading this book, you will create XML collections within local database files, with no database server or configuration needed. You’ll learn to use the W3C XQuery language to perform sophisticated queries across multiple data sources, compute hierarchical set operations, and reshape the results to output entirely new XML (or non-XML). Flexible indexing, per- document metadata, transactions, recovery, and support for all major operat- ing systems and programming languages add up to a data solution you’ll be glad you found—and a book that shows you how. Danny Brian Shelve in Databases User level: Beginner–Intermediate Berkeley DB XML Brian ISBN 1-59059-666-8 9 781590 596661 90000 6 89253 59666 1 Companion eBook Available RELATED TITLES The Definitive Guide to www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version forums.apress.com FOR PROFESSIONALS BY PROFESSIONALS ™ Join online discussions: Danny Brian The Definitive Guide to Berkeley DB XML 6668fm.qxd 7/20/06 3:38 PM Page i The Definitive Guide to Berkeley DB XML Copyright © 2006 by Danny Brian All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13: 978-1-59059-666-1 ISBN-10: 1-59059-666-8 Library of Congress Cataloging-in-Publication data is available upon request. Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Matt Wade Technical Reviewer: George Feinberg Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick, Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft, Jim Sumser, Keir Thomas, Matt Wade Project Manager: Kylie Johnston Copy Edit Manager: Nicole LeClerc Copy Editor: Nancy Sixsmith Assistant Production Director: Kari Brooks-Copony Production Editor: Kelly Winquist Compositor: Molly Sharp Proofreader: Linda Seifert Indexer: John Collin Artist: April Milne Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com, or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com in the Source Code section. 6668fm.qxd 7/20/06 3:38 PM Page ii For the late Darrel Danner who taught me authenticity 6668fm.qxd 7/20/06 3:38 PM Page iii 6668fm.qxd 7/20/06 3:38 PM Page iv Contents at a Glance About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix ■CHAPTER 1 A Quick Look at Berkeley DB XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 ■CHAPTER 2 The Power of an Embedded XML Database . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 ■CHAPTER 3 Installation and Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 ■CHAPTER 4 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 ■CHAPTER 5 Environments, Containers, and Documents . . . . . . . . . . . . . . . . . . . . . . . . . . 47 ■CHAPTER 6 Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 ■CHAPTER 7 XQuery with BDB XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 ■CHAPTER 8 BDB XML with C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 ■CHAPTER 9 BDB XML with Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 ■CHAPTER 10 BDB XML with Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 ■CHAPTER 11 BDB XML with Perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 ■CHAPTER 12 BDB XML with PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 ■CHAPTER 13 Managing Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 ■APPENDIX A XML Essentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 ■APPENDIX B BDB XML API Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 ■APPENDIX C XQuery Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 ■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 v 6668fm.qxd 7/20/06 3:38 PM Page v 6668fm.qxd 7/20/06 3:38 PM Page vi Contents vii About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix ■CHAPTER 1 A Quick Look at Berkeley DB XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 A Complete Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Creating and Using a Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Querying a Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Creating and Querying a Second Database . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 XQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 ■CHAPTER 2 The Power of an Embedded XML Database . . . . . . . . . . . . . . . . . . . 7 Database Servers vs. Embedded Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Architecture Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Embedded Databases You Might Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 SQLite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Wordnet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Embedded Databases on the Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 XML for Data Exchange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 XML for Data Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Indexing XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 High-Performance XML Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 BDB XML for Quality Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 ■CHAPTER 3 Installation and Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 BDB XML Packages and Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Berkeley DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Xerces C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Pathan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 6668fm.qxd 7/20/06 3:38 PM Page vii XQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Berkeley DB XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Unix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Building and Using Individual Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Unix Variants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Building Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 ■CHAPTER 4 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Core Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 The Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Shell Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Creating Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Adding and Deleting Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Querying Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Indexing Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Using XQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 ■CHAPTER 5 Environments, Containers, and Documents . . . . . . . . . . . . . . . . . . 47 Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Creating and Opening Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Additional Environment Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Creating and Opening Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Container Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Some Container Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Adding Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Retrieving a Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Replacing Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Modifying Documents Programmatically . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Deleting Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 ■CONTENTSviii 6668fm.qxd 7/20/06 3:38 PM Page viii ■CHAPTER 6 Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Creating and Manipulating Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Index Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Index Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Uniqueness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Path Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Node Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Key Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Syntax Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Managing Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Adding Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Listing Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Deleting and Replacing Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Default Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Index Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Query Plans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 ■CHAPTER 7 XQuery with BDB XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Trying XQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Sample Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 XPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 A Complete Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 FLWOR Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 let . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 where . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 order by . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 return . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Atomic Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 User Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Some XQuery Tricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Iteration vs. Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Querying for Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 ■CONTENTS ix 6668fm.qxd 7/20/06 3:38 PM Page ix [...]... in the area of document storage, and I am quite happy with the results The Definitive Guide to Berkeley DB XML is not an exhaustive treatment of XQuery, XML, or related technologies This book instead pulls them together as used by Berkeley DB XML and gives you everything you need to know about them to work with it xix 6668fm.qxd xx 7/20/06 3:38 PM Page xx sINTRODUCTION How This Book Is Structured The. .. use these files to populate a BDB XML database Creating and Using a Database Like BDB, a BDB XML database is a file on disk and is typically referred to as a container Your application opens, reads, and writes to this file directly Assuming that we have these XML files in the current directory, the following example uses the dbxml command-line utility—available as part of the BDB XML distribution to. .. using the same XQuery expressions, meaning it will be available for the same query processing as if it were XML in the documents Here, we add a price metadata attribute to the book file we added previously and then add an index for it to the container: dbxml> openContainer books.dbxml dbxml> setMetaData 0553211757 .xml '' price decimal 10.95 MetaData item 'price' added to document 0553211757 .xml dbxml>... The Definitive Guide to Berkeley DB XML is for any developer who works with XML, whatever the application I included an XML overview (Appendix A XML Essentials”) for developers who aren’t necessarily familiar with XML The early chapters address programmers who might be unconvinced of the benefits of either an embedded database or the benefits of XML itself, but there’s also plenty of information there... 7 2 The Power of an Embedded XML Database S leepycat’s Berkeley DB XML (BDB XML) is an embedded database used to store and index XML documents Immediately, two core philosophies require some exploration: embedded storage and XML itself The exploration is riddled— surprisingly to some, old news to others—with biases on all sides This chapter clarifies the issues and explains the cases where and the. .. different servers The program needs to include libraries for each protocol because they are unlikely to be different To enforce the game rules, the multiuser server probably needs to query the database to know, for example, whether a given object is in a given area And we probably want users to have to authenticate to the multiuser server to begin with, meaning it will already be querying the database—assuming... and even rewrite XML to another dialect Metadata For the example here, there is a lot of data we want to associate with a book record, including the price and perhaps a sales ranking This is data we expect to change frequently, and we’d rather not have to change our book XML to accommodate it (if, for example, the XML is data shared with resellers) BDB XML enables metadata to be added to documents in... index format The entries are in alphabetical order I won’t delve into the details, other than to observe that the index entry duplicates information that is also found in the records themselves The data in the index is space-delimited (requiring spaces in the word itself to be replaced with underscores) The offset numbers at the end identify the location of the records in the data file There are two... Because it wanted to move into the XML application space, Sleepycat (with the primary participation of John Merrells) developed BDB XML as a layer atop BDB Today, BDB XML boasts a sophisticated query engine using XQuery with query plan optimization and flexible indexing It also inherits the transaction features of BDB This chapter gives a brief overview of BDB XML for those familiar with the core concepts:... call it The Man The bottom line is that I now have an astonishing array of tools and technologies, all compatible, to work with data as I like Until recently, a database was the big missing link; I had to convert data to and from SQL to index it Eventually, XML databases began to pop up But even as they did, I was unhappy with their design: most were language-specific, some were just XML -to- RDB interfaces, . PROFESSIONALS ™ Join online discussions: Danny Brian The Definitive Guide to Berkeley DB XML 6668fm.qxd 7/20/06 3:38 PM Page i The Definitive Guide to Berkeley DB XML Copyright © 2006 by Danny Brian All. written if the author isn’t excited by the subject matter. I want to assure you that this is the case for The Definitive Guide to Berkeley DB XML. I wanted this book to exist because BDB XML has. Brian The Definitive Guide to Berkeley DB XML Simplify your storage, processing, and retrieval of data with embedded XML databases. BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® The Definitive Guide to

Ngày đăng: 01/06/2014, 12:37

Từ khóa liên quan

Mục lục

  • The Definitive Guide to Berkeley DB XML

    • Table of Content

    • Chapter 1 A Quick Look at Berkeley DB XML

    • Chapter 2 The Power of an Embedded XML Database

    • Chapter 3 Installation and Configuration

    • Chapter 4 Getting Started

    • Chapter 5 Environments, Containers, and Documents

    • Chapter 6 Indexes

    • Chapter 7 XQuery with BDB XML

    • Chapter 8 BDB XML with C++

    • Chapter 9 BDB XML with Python

    • Chapter 10 BDB XML with Java

    • Chapter 11 BDB XML with Perl

    • Chapter 12 BDB XML with PHP

    • Chapter 13 Managing Databases

    • Appendix A XML Essentials

    • Appendix B BDB XML API Reference

    • Appendix C XQuery Reference

    • Index

Tài liệu cùng người dùng

Tài liệu liên quan