[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Smoothness of operations between rational and xml

  • From: Dmitry Turin <sql4-en@n...>
  • To: xml-dev@l...
  • Date: Mon, 5 Nov 2007 16:27:56 +0200

Smoothness of operations between rational and xml
I propose to use XPath inside SQL with the following agreements:

a/@a1
  field "a1" in table "a" or attribute "a1" in XML-element "a"
@a1/@b2
  rational field "b2" in rational field "a1" (created by "row")
a/b
  table or XML-element "b", enclosed into table or XML-element "a"
@a1/b
  XML-element "b" in rational field "a1"

So XPath unify rational table and xml-element into some tabment (TABle-eleMENT),
and rational field and xml-attribute into some fattrib (Field-ATTRIBute).
I also propose XTree (a.b.c), similar to XPath (a/b/c).
Thus SQL-operations between rational and xml will be much smoother.
For example, inserting from rational into xml and vise verse:
  insert into tab (fld) values ('<tag>...</tag>');
  insert into tab (fld) select a.b.c;             -- executed as [1]

  insert into tab values ('<tag>...</tag>');      -- no field after 'tab'
  insert into tab select a.b;                     -- executed as [2]
  
inserting into xml and extraction from it
  insert into tab/@fld/k/m/n values ('<tag>...</tag>');
  insert into tab/@fld/k/m/n select a.b.c;

  insert into tabname (field) select tab/@fld/k/m/n/a.b.c;

updating of xml-attribute and xml-content (if to designate content as @@)
  update tab set @fld/p/q/r/@r1=( select a.b.c                );
  update tab set @fld/p/q/r/@r1=( select t/@field/k/m/n/a.b.c );
  update tab set @fld/p/q/r/@r1='<a>...</a>';

  update tab set @fld/p/q/@@=( select a.b.c                );
  update tab set @fld/p/q/@@=( select t/@field/k/m/n/a.b.c );
  update tab set @fld/p/q/@@='<a>...</a>';

deleting
  delete from tab/@fld/k/m/n;

We also can specify predicates
  where @fld/k/m/n/@n1 =  5;
  where @fld/k/m/n/@n1 in (select a1 from a);
  where @fld/k/m/n/@@  =  '<tag>...</tag>';
  where @fld/k/m/n     in (select a/b/n);

permissions
  grant  insert on tab/@fld/k/m/n to   UserName;
  revoke delete on tab/@fld/k/m/n from UserName;

and triggers
  create trigger TriggerName for tab/@fld/k/m/n
  after insert as begin
    ...
  end;;

More detail is in http://sql50.euro.ru/site/sql50/en/author/sql-xml_eng.htm


  
[1]
insert into tab (fld) values ('
  <a     id=1   data=12.3>
    <b   id=10  data=23.4>
      <c id=100 data=56.7/>
      <c id=101 data=67.8/>
    </b>
    <b   id=20  data=34.5>
      <c id=200 data=78.9/>
      <c id=201 data=89.1/>
    </b>
    <b   id=30  data=45.6>
      <c id=200 data=91.2/>
    </b>
  </a>
');

[2]
--request is equivalent to the DML
insert into tab values ('
  <a        data=12.3>
    <b      data=23.4>
    <b      data=34.5>
    <b      data=45.6>
  </a>
');

--at condition of following DDL
create table a (
  id   num      primary key,
  lnk  num      references tab,
  data float
);
create table b (
  id   num      primary key,
  ref  num      references a(id),
  data float
);

--request is executed so
insert into tab values (1);
insert into a   values (10, 1, 12.3);
insert into b   values (101,10,23.4);
insert into b   values (102,10,34.5);
insert into b   values (103,10,45.6);



Dmitry Turin
SQL5      (5.7.0)  http://sql50.euro.ru
HTML6     (6.5.0)  http://html60.euro.ru
Unicode7  (7.2.1)  http://unicode70.euro.ru
Computer2 (2.0.2)  http://computer20.euro.ru



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.