<s>
Object	B-General_Concept
–	I-General_Concept
relational	I-General_Concept
mapping	I-General_Concept
(	O
ORM	O
,	O
O/RM	B-General_Concept
,	O
and	O
O/R	B-General_Concept
mapping	I-General_Concept
tool	O
)	O
in	O
computer	B-General_Concept
science	I-General_Concept
is	O
a	O
programming	B-General_Concept
technique	O
for	O
converting	O
data	O
between	O
a	O
relational	O
database	O
and	O
the	O
heap	B-Application
of	O
an	O
object-oriented	B-Language
programming	I-Language
language	I-Language
.	O
</s>
<s>
This	O
creates	O
,	O
in	O
effect	O
,	O
a	O
virtual	O
object	B-Application
database	I-Application
that	O
can	O
be	O
used	O
from	O
within	O
the	O
programming	B-General_Concept
language	O
.	O
</s>
<s>
In	O
object-oriented	B-Language
programming	I-Language
,	O
data-management	B-General_Concept
tasks	O
act	O
on	O
objects	O
that	O
combine	O
scalar	O
values	O
into	O
objects	O
.	O
</s>
<s>
This	O
could	O
be	O
modeled	O
in	O
an	O
object-oriented	B-Language
implementation	O
by	O
a	O
"	O
Person	O
object	O
"	O
with	O
an	O
attribute/field	B-General_Concept
to	O
hold	O
each	O
data	O
item	O
that	O
the	O
entry	O
comprises	O
:	O
the	O
person	O
's	O
name	O
,	O
a	O
list	O
of	O
phone	O
numbers	O
,	O
and	O
a	O
list	O
of	O
addresses	O
.	O
</s>
<s>
Each	O
such	O
address-book	O
entry	O
is	O
treated	O
as	O
a	O
single	O
object	O
by	O
the	O
programming	B-General_Concept
language	O
(	O
it	O
can	O
be	O
referenced	O
by	O
a	O
single	O
variable	O
containing	O
a	O
pointer	O
to	O
the	O
object	O
,	O
for	O
instance	O
)	O
.	O
</s>
<s>
Various	O
methods	B-Language
can	O
be	O
associated	O
with	O
the	O
object	O
,	O
such	O
as	O
methods	B-Language
to	O
return	O
the	O
preferred	O
phone	O
number	O
,	O
the	O
home	O
address	O
,	O
and	O
so	O
on	O
.	O
</s>
<s>
By	O
contrast	O
,	O
relational	O
databases	O
,	O
such	O
as	O
SQL	B-Language
,	O
group	O
scalars	O
into	O
tuples	B-Application
,	O
which	O
are	O
then	O
enumerated	O
in	O
tables	B-Application
.	O
</s>
<s>
Tuples	B-Application
and	O
objects	O
have	O
some	O
general	O
similarity	O
,	O
in	O
that	O
they	O
are	O
both	O
ways	O
to	O
collect	O
values	O
into	O
named	O
fields	O
such	O
that	O
the	O
whole	O
collection	O
can	O
be	O
manipulated	O
as	O
a	O
single	O
compound	O
entity	O
.	O
</s>
<s>
They	O
have	O
many	O
differences	O
,	O
though	O
,	O
in	O
particular	O
:	O
lifecycle	O
management	O
(	O
row	O
insertion	O
and	O
deletion	O
,	O
versus	O
garbage	O
collection	O
or	O
reference	B-General_Concept
counting	I-General_Concept
)	O
,	O
references	O
to	O
other	O
entities	O
(	O
object	O
references	O
,	O
versus	O
foreign	O
key	O
references	O
)	O
,	O
and	O
inheritance	O
(	O
non-existent	O
in	O
relational	O
databases	O
)	O
.	O
</s>
<s>
As	O
well	O
,	O
objects	O
are	O
managed	O
on-heap	O
and	O
are	O
under	O
full	O
control	O
of	O
a	O
single	O
process	O
,	O
while	O
database	O
tuples	B-Application
are	O
shared	O
and	O
must	O
incorporate	O
locking	O
,	O
merging	O
,	O
and	O
retry	O
.	O
</s>
<s>
Object	B-General_Concept
–	I-General_Concept
relational	I-General_Concept
mapping	I-General_Concept
provides	O
automated	O
support	O
for	O
mapping	O
tuples	B-Application
to	O
objects	O
and	O
back	O
,	O
while	O
accounting	O
for	O
all	O
of	O
these	O
differences	O
.	O
</s>
<s>
If	O
this	O
storage	O
and	O
retrieval	O
functionality	O
is	O
implemented	O
,	O
the	O
objects	O
are	O
said	O
to	O
be	O
persistent	B-Application
.	O
</s>
<s>
Implementation-specific	O
details	O
of	O
storage	O
drivers	O
are	O
generally	O
wrapped	O
in	O
an	O
API	O
in	O
the	O
programming	B-General_Concept
language	O
in	O
use	O
,	O
exposing	O
methods	B-Language
to	O
interact	O
with	O
the	O
storage	O
medium	O
in	O
a	O
way	O
which	O
is	O
simpler	O
and	O
more	O
in	O
line	O
with	O
the	O
paradigms	O
of	O
surrounding	O
code	O
.	O
</s>
<s>
The	O
following	O
is	O
a	O
simple	O
example	O
,	O
written	O
in	O
C#	B-Application
code	O
,	O
to	O
execute	O
a	O
query	O
written	O
in	O
SQL	B-Language
using	O
a	O
database	O
engine	O
.	O
</s>
<s>
The	O
case	O
above	O
makes	O
use	O
of	O
an	O
object	O
representing	O
the	O
storage	O
repository	O
and	O
methods	B-Language
of	O
that	O
object	O
.	O
</s>
<s>
Other	O
frameworks	O
might	O
provide	O
code	O
as	O
static	B-Language
methods	I-Language
,	O
as	O
in	O
the	O
example	O
below	O
,	O
and	O
yet	O
other	O
methods	B-Language
may	O
not	O
implement	O
an	O
object-oriented	B-Language
system	O
at	O
all	O
.	O
</s>
<s>
Compared	O
to	O
traditional	O
techniques	O
of	O
exchange	O
between	O
an	O
object-oriented	B-Language
language	I-Language
and	O
a	O
relational	O
database	O
,	O
ORM	O
often	O
reduces	O
the	O
amount	O
of	O
code	O
that	O
needs	O
to	O
be	O
written	O
.	O
</s>
<s>
Disadvantages	O
of	O
ORM	O
tools	O
generally	O
stem	O
from	O
the	O
high	O
level	O
of	O
abstraction	B-Application
obscuring	O
what	O
is	O
actually	O
happening	O
in	O
the	O
implementation	O
code	O
.	O
</s>
<s>
Another	O
approach	O
is	O
to	O
use	O
an	O
object-oriented	B-Application
database	I-Application
management	I-Application
system	I-Application
(	O
OODBMS	B-Application
)	O
or	O
document-oriented	B-General_Concept
databases	I-General_Concept
such	O
as	O
native	O
XML	B-Application
databases	I-Application
that	O
provide	O
more	O
flexibility	O
in	O
data	O
modeling	O
.	O
</s>
<s>
OODBMSs	O
are	O
databases	O
designed	O
specifically	O
for	O
working	O
with	O
object-oriented	B-Language
values	O
.	O
</s>
<s>
Using	O
an	O
OODBMS	B-Application
eliminates	O
the	O
need	O
for	O
converting	O
data	O
to	O
and	O
from	O
its	O
SQL	B-Language
form	O
,	O
as	O
the	O
data	O
is	O
stored	O
in	O
its	O
original	O
object	O
representation	O
and	O
relationships	O
are	O
directly	O
represented	O
,	O
rather	O
than	O
requiring	O
join	O
tables/operations	O
.	O
</s>
<s>
The	O
equivalent	O
of	O
ORMs	O
for	O
document-oriented	B-General_Concept
databases	I-General_Concept
are	O
called	O
object-document	O
mappers	O
(	O
ODMs	O
)	O
.	O
</s>
<s>
Document-oriented	B-General_Concept
databases	I-General_Concept
also	O
prevent	O
the	O
user	O
from	O
having	O
to	O
"	O
shred	O
"	O
objects	O
into	O
table	B-Application
rows	I-Application
.	O
</s>
<s>
Many	O
of	O
these	O
systems	O
also	O
support	O
the	O
XQuery	B-Language
query	O
language	O
to	O
retrieve	O
datasets	O
.	O
</s>
<s>
Object-oriented	B-Application
databases	I-Application
tend	O
to	O
be	O
used	O
in	O
complex	O
,	O
niche	O
applications	O
.	O
</s>
<s>
One	O
of	O
the	O
arguments	O
against	O
using	O
an	O
OODBMS	B-Application
is	O
that	O
it	O
may	O
not	O
be	O
able	O
to	O
execute	O
ad-hoc	O
,	O
application-independent	O
queries	O
.	O
</s>
<s>
For	O
this	O
reason	O
,	O
many	O
programmers	O
find	O
themselves	O
more	O
at	O
home	O
with	O
an	O
object-SQL	B-General_Concept
mapping	I-General_Concept
system	O
,	O
even	O
though	O
most	O
object-oriented	B-Application
databases	I-Application
are	O
able	O
to	O
process	O
SQL	B-Language
queries	O
to	O
a	O
limited	O
extent	O
.	O
</s>
<s>
Other	O
OODBMS	B-Application
provide	O
replication	O
to	O
SQL	B-Language
databases	I-Language
,	O
as	O
a	O
means	O
of	O
addressing	O
the	O
need	O
for	O
ad-hoc	O
queries	O
,	O
while	O
preserving	O
well-known	O
query	O
patterns	O
.	O
</s>
<s>
A	O
variety	O
of	O
difficulties	O
arise	O
when	O
considering	O
how	O
to	O
match	O
an	O
object	B-Language
system	I-Language
to	O
a	O
relational	O
database	O
.	O
</s>
<s>
These	O
difficulties	O
are	O
referred	O
to	O
as	O
the	O
object	B-Architecture
–	I-Architecture
relational	I-Architecture
impedance	I-Architecture
mismatch	I-Architecture
.	O
</s>
<s>
These	O
can	O
be	O
called	O
from	O
the	O
client	O
using	O
SQL	B-Language
statements	O
.	O
</s>
<s>
The	O
Data	O
Access	O
Object	O
(	O
DAO	O
)	O
design	O
pattern	O
is	O
used	O
to	O
abstract	O
these	O
statements	O
and	O
offer	O
a	O
lightweight	O
object-oriented	B-Language
interface	O
to	O
the	O
rest	O
of	O
the	O
application	O
.	O
</s>
