Download XML datu glab**anas varianti Oracle XML DB datu b*z*

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Microsoft Jet Database Engine wikipedia , lookup

SQL wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Oracle Database wikipedia , lookup

Database wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Relational model wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Object-relational impedance mismatch wikipedia , lookup

Clusterpoint wikipedia , lookup

Database model wikipedia , lookup

Transcript
1
XML tehnoloģiju attīstība
2
XMLType datu tips
1. XMLType ir abstrakts datu tips XML datu glabāšanai un apstrādei
datu bāzē.
2. XMLType iekļauj metodes XML datu izveidošanai, izgūšanai un
indeksēšanai.
3. XMLType ļauj datu izgūšanu veikt ar SQL valodas palīdzību.
4. XMLType tipa mainīgie var tikt lietoti PL/SQL glabājamās
procedūrās (stored procedures) kā parametri un atgriešanas (return)
vērtības.
5. XMLType tipu var izmantot SQL, PL/SQL, C, Java (lietojot JDBC)
un Oracle Data Provider for .NET (ODP.NET).
3
XML datu glabāšanas varianti
4
XML datu glabāšana izmantojot XMLType datu tipu
1. XML datu glabāšana tabulas rindās ar XMLType tipa objektiem.
2. XML datu glabāšana XMLType tipa tabulas kolonās.
3. Datus XML tipa tabulas rindā vai kolonā var glabāt trīs veidos:
1) nestrukturētā veidā – XMLType dati tiek glabāti Character
Large Object (CLOB) tipa struktūrās;
2) strukturētā veidā – XMLType dati tiek glabāti kā objektu kopa
relāciju-objektu datu bāzē. Šo glabāšanas veidu tāpēc sauc arī
par XML datu objektu – relāciju glabāšanu.
3) binārā veidā – XMLType dati tiek glabāti izanalizētā un
sakārtotā veidā (post – parsed), binārā formātā, kas ir izveidots
tieši XML datu glabāšanai (sākot ar Oracle11g).
efektīvākais glabāšanas veids.
Tas ir
5
XML datu glabāšanas veidi datu bāzē
Structured (object-relational) storage advantages over the other storage models
include near-relational query and update performance, optimized memory
management, reduced storage requirements, B-tree indexing, and in-place updates.
These advantages are at a cost of increased processing overhead during ingestion and
full retrieval of XML data, and reduced flexibility in the structure of the XML that
can be managed by a given XMLType table or column. Structural flexibility is
reduced because data and metadata (such as column names) are separated in objectrelational storage. Instance structures cannot vary easily. Structured storage is
particularly appropriate for highly structured data whose structure does not vary, if
this maps to a manageable number of database tables and joins.
Unstructured (CLOB) storage enables higher throughput than structured storage
when inserting and retrieving entire XML documents. No data conversion is needed,
so the same format can be used outside the database. Unstructured storage also
provides greater flexibility than structured storage in the structure of the XML that
can be stored. Unstructured storage is particularly appropriate for document-centric
use cases. These advantages can come at the expense of certain aspects of intelligent
processing: in the absence of indexing, there is little that the database can do to
optimize queries or updates on XML data that is stored in a CLOB instance. In
particular, the cost of XML parsing (often implicit) can significantly impact query
performance. Indexing with XMLIndex can improve the performance of queries
against unstructured storage.
Binary XML storage provides more efficient database storage, updating, indexing,
and fragment extraction than unstructured storage. It can provide better query
performance than unstructured storage — it does not suffer from the XML parsing
bottleneck (it is a post-parse persistence model). Like structured storage, binary XML
storage is aware of XML Schema data types and can take advantage of native
database data types. Like structured storage, binary XML storage allows for
piecewise updates. Because binary XML data can also be used outside the database, it
can serve as an efficient XML exchange medium, and you can off load work from the
database to increase overall performance in many cases. Like unstructured storage,
binary XML data is kept in document order. Like structured storage, data and
metadata can, using binary storage, be separated at the database level, for efficiency.
Like unstructured storage, however, binary XML storage allows for intermixed data
and metadata, which lets instance structures vary. Binary XML storage allows for
very complex and variable data, which in the structured-storage model could
necessitate using many database tables. Unlike the other XMLType storage models,
you can use binary storage for XML schema-based data even if the XML schema is
not known beforehand, and you can store multiple XML schemas in the same table
and query across common elements.
6
XML dokumenta glabāšana XMLType datu tipa
tabulas kolonnā
XML dokuments
Datu bāze
T1
XMLType
K1
Strukturētais
glabāšanas veids
Binārais glabāšanas
veids
Nestrukturētais
glabāšanas veids
<?xml version="1.0" encoding="UTF-8"?>
<darbinieki>
<darbinieks>
<darbinieks_id>1</darbinieks_id>
<vards>Jānis</vards>
<uzvards>Bērziņš</uzvards>
</darbinieks>
<darbinieks>
<darbinieks_id>2</darbinieks_id>
<vards>Pēteris</vards>
<uzvards>Kalniņš</uzvards>
</darbinieks>
</darbinieki>
XML shēma
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="darbinieki">
<xs:complexType>
<xs:sequence>
<xs:element ref="darbinieks" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="darbinieks">
<xs:complexType>
<xs:sequence>
<xs:element ref="darbinieks_id" />
<xs:element ref="vards" />
<xs:element ref="uzvards" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="darbinieks_id">
<xs:complexType mixed="true" />
</xs:element>
<xs:element name="uzvards">
<xs:complexType mixed="true" />
</xs:element>
</xs:schema>
7
XMLType datu glabāšanas veidi
Nestrukturētā un binārā glabāšanas veida norādīšanai jālieto STORE AS izteiksme
CREATE TABLE komandā.
8
Uz datiem un uz dokumentiem orientētie XML avoti
9
XML dokumentu shēmas izmantošana datu bāzē
10
XMLType tipu glabāšanas variantu priekšrocības
Structured (ObjectBinary XML Storage
Relational) Storage
– XML decomposition can
+ High throughput. Fast
result in reduced
DOM loading. There is a
throughput when ingesting
slight overhead from the
Throughput
or retrieving the entire
binary XML
content of an XML
encoder/decoder.
document.
+ Streaming XPath
evaluation avoids DOM
construction and allows
evaluation of multiple XPath
++ Extremely fast:
expressions in a single pass.
relational query
Navigational XPath
performance.
evaluation is significantly
Queries
faster than with unstructured
You can create B-tree
indexes on the underlying storage.
object-relational columns.
XMLIndex indexing can
improve performance of
XPath-based queries.
Quality
Update
operations
(DML)
++ Extremely fast:
relational columns are
updated in place.
+ In-place, piecewise update
for SecureFile LOB storage.
Space
efficiency
(disk)
++ Extremely spaceefficient.
+ Space-efficient.
– Limited flexibility. Only
+ Flexibility in the structure
documents that conform to
of the XML documents that
Data
the XML schema can be
flexibility
can be stored in an XMLType
stored in the XMLType
column or table.
table or column.
– An XMLType table can
only store documents that ++ Can store XML schemaconform to the same XML based or non-schema-based
XML schema schema.
documents. An XMLType
flexibility
table can store documents
that conform to any
In-place XML schema
registered XML schemas.
evolution is available,
with some restrictions.
DOM fidelity: A DOM
created from an XML
DOM fidelity (see structured
XML fidelity document that has been
storage description).
stored in the database is
identical to a DOM
Unstructured (CLOB)
Storage
++ High throughput when
ingesting and retrieving
the entire content of an
XML document.
– XPath operations are
evaluated by constructing
a DOM from the CLOB
data and using functional
evaluation. Expensive
when performing
operations on large
documents or large
collections of documents.
XMLIndex
indexing can
improve performance of
XPath-based queries.
– When any part of the
document is updated, the
entire document must be
written back to disk.
– Consumes the most disk
space, due to insignificant
whitespace and repeated
tags.
+ Flexibility in the
structure of the XML
documents that can be
stored in an XMLType
column or table.
++ Can store XML
schema-based or nonschema-based documents.
Cannot use multiple XML
schemas for the same
XMLType table.
+ Document fidelity:
Maintains the original
XML data, byte for byte.
In particular, all original
whitespace is preserved.
11
Quality
Structured (ObjectRelational) Storage
created from the original
document. However,
insignificant whitespace
may be discarded.
+ B-tree, bitmap, Oracle
Text, XMLIndex, and
function-based indexes.
Binary XML Storage
Unstructured (CLOB)
Storage
XMLIndex,
functionbased, and Oracle Text
indexes.
– XML operations on the
Optimized + XML operations can be + XML operations can be
document require creating
optimized to reduce
optimized to reduce memory
memory
a DOM from the
requirements.
management memory requirements.
document.
XML data is partially
+ XML schema-based data is XML schema-based data
Validation
validated when it is
fully validated when it is
is partially validated when
upon insert
inserted.
inserted.
it is inserted.
XMLType columns can be
Partition based on virtual
partitioned if the
Partitioning + Available.
columns.
partitioning key is a
relational column.
Streams– Not available.
– Not available.
++ Available.
based
replication
++ XML elements and
+ XML data that uses
SecureFile LOB storage can – Not available.
Compression attributes can be
compressed individually. be compressed.
Indexing
support
XMLIndex,
function-based,
and Oracle Text indexes.
12
XMLType datu tipa izmantošanas kopējā shēma
JDBC
Tiešā HTTP
pieeja
Oracle Net
Services
pieeja
Oracle
Streams AQ
pieeja
FTP un
WebDAV
pieeja
Datu bāze
HTTP protokola
apdarinātājs
(handler)
Indeksi:
1) B koka tipa;
2) tekstu indeksi;
3) indeksi ar
funkciju
izmantošanu;
4) Oracle teksta
(Oracle Text).
DAV, FTP
protokola
apdarinātāji
(handlers)
SQL dzinis
(engine)
XML shēmas (XML Schemas)
XMLType tipa
tabulas un
tabulas ar
XMLType tipa
kolonnām
Repozitorijs
XMLType tipa
skati
Hierarhiskie
indeksi
Binārais glabāšanas veids
Nestrukturētais
glabāšanas veids
Strukturētais glabāšanas
veids
Lokālas tabulas
DBLinks
Oracle XML DB
Ārējās tabulas