Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Object–relational database
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Comparison to RDBMS == An RDBMS might commonly involve [[SQL]] statements such as these: <syntaxhighlight lang="mysql"> CREATE TABLE Customers ( Id CHAR(12) NOT NULL PRIMARY KEY, Surname VARCHAR(32) NOT NULL, FirstName VARCHAR(32) NOT NULL, DOB DATE NOT NULL # DOB: Date of Birth ); SELECT InitCap(C.Surname) || ', ' || InitCap(C.FirstName) FROM Customers C WHERE Month(C.DOB) = Month(getdate()) AND Day(C.DOB) = Day(getdate()) </syntaxhighlight> Most {{As of|2007|alt=current}} SQL databases allow the crafting of custom [[function (computer science)|function]]s, which would allow the query to appear as: <syntaxhighlight lang="mysql"> SELECT Formal(C.Id) FROM Customers C WHERE Birthday(C.DOB) = Today() </syntaxhighlight> <!-- NOTE: Rather than fix this, only to have it unfixed ''yet'' again, let it stand as an example. The first SQL SELECT statement quoted above is both non-standard, and wrong. InitCap() isn't SQL-92 (or SQL-3), and the query's logic misses Customers born on a leap-day (171,000 United States citizens) for three years out of four. --> In an object–relational database, one might see something like this, with user-defined data-types and expressions such as <code>BirthDay()</code>: <syntaxhighlight lang="postgres"> CREATE TABLE Customers ( Id Cust_Id NOT NULL PRIMARY KEY, Name PersonName NOT NULL, DOB DATE NOT NULL ); SELECT Formal( C.Id ) FROM Customers C WHERE BirthDay ( C.DOB ) = TODAY; </syntaxhighlight> The object–relational model can offer another advantage in that the database can make use of the relationships between data to easily collect related records. In an [[address book]] application, an additional table would be added to the ones above to hold zero or more addresses for each customer. Using a traditional RDBMS, collecting information for both the user and their address requires a "join": <syntaxhighlight lang="mysql"> SELECT InitCap(C.Surname) || ', ' || InitCap(C.FirstName), A.city FROM Customers C JOIN Addresses A ON A.Cust_Id=C.Id -- the join WHERE A.city="New York" </syntaxhighlight> The same query in an object–relational database appears more simply: <syntaxhighlight lang="postgres"> SELECT Formal( C.Name ) FROM Customers C WHERE C.address.city="New York" -- the linkage is 'understood' by the ORDB </syntaxhighlight>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Object–relational database
(section)
Add topic