Loading ...
Sorry, an error occurred while loading the content.

Map element twice problem

Expand Messages
  • greeley304
    Hi, my map problem have the map element problem again. I have to generate the order of the mattext and matimg element, so i wrote a order table to generate the
    Message 1 of 4 , Nov 20, 2002
    • 0 Attachment
      Hi, my map problem have the map element problem again. I have to
      generate the order of the mattext and matimg element, so i wrote a
      order table to generate the order.
      Here is my work:
      sql:
      create table material_table(
      material_id serial primary key,
      id int4
      )WITH OIDS;

      create table mattext_table(
      mattext_id serial primary key,
      material_id int4,
      mattext_data varchar(255),
      CONSTRAINT mattext_material_fk FOREIGN KEY (material_id)
      REFERENCES material_table (material_id)
      )WITH OIDS;

      create table matimg_table(
      matimg_id serial primary key,
      material_id int4,
      matimg_data varchar(255),
      CONSTRAINT matimg_material_fk FOREIGN KEY (material_id)
      REFERENCES material_table (material_id)
      )WITH OIDS;

      create table mattex_matimg_order_table(
      order_id serial primary key,
      mattext_id int4,
      matimg_id int4,
      material_id int4,
      item_order int4,
      CONSTRAINT order_mattext_fk FOREIGN KEY (mattext_id)
      REFERENCES mattext_table (mattext_id),
      CONSTRAINT order_matimg_fk FOREIGN KEY (matimg_id)
      REFERENCES matimg_table (matimg_id),
      CONSTRAINT order_material_fk FOREIGN KEY (material_id)
      REFERENCES material_table (material_id)
      )WITH OIDS;
      xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <root>
      <material id="11">
      <mattext>Size</mattext>
      <matimg>link1</matimg>
      </material>
      <material id="22">
      <mattext>Pics</mattext>
      <matimg>link2</matimg>
      <mattext>link3</mattext>
      </material>
      </root>
      map:
      <Maps>
      <ClassMap>
      <ElementType Name="material"/>
      <ToClassTable Name="material_table"/>
      <PropertyMap>
      <Attribute Name="id"/>
      <ToColumn Name="id"/>
      </PropertyMap>
      <PropertyMap>
      <ElementType Name="mattext"/>
      <ToPropertyTable Name="mattext_table"
      KeyInParentTable="Unique">
      <UseUniqueKey Name="PrimaryKey"/>
      <UseForeignKey Name="mattext_material_fk"/>
      <ToColumn Name="mattext_data"/>
      </ToPropertyTable>
      </PropertyMap>
      <PropertyMap>
      <ElementType Name="matimg"/>
      <ToPropertyTable Name="matimg_table"
      KeyInParentTable="Unique">
      <UseUniqueKey Name="PrimaryKey"/>
      <UseForeignKey Name="matimg_material_fk"/>
      </ToPropertyTable>
      <ToColumn Name="matimg_data"/>
      </PropertyMap>
      <RelatedClass KeyInParentTable="Unique">
      <ElementType Name="mattext"/>
      <UseUniqueKey Name="PrimaryKey"/>
      <UseForeignKey Name="order_mattext_fk"/>
      </RelatedClass>
      <RelatedClass KeyInParentTable="Unique">
      <ElementType Name="matimg"/>
      <UseUniqueKey Name="PrimaryKey"/>
      <UseForeignKey Name="order_matimg_fk"/>
      </RelatedClass>
      <RelatedClass KeyInParentTable="Unique">
      <ElementType Name="material"/>
      <UseUniqueKey Name="PrimaryKey"/>
      <UseForeignKey Name="order_material_fk"/>
      <OrderColumn Name="item_order" Generate="Yes"/>
      </RelatedClass>
      </ClassMap>
      </Maps>

      In the map file, i should use the mattext and matimg again in order
      to write the relatedclass code for the foreign key. But i reuse the
      same element. Is it any way i can use the element twice?
      Thank u very much.
    • Ronald Bourret
      1) You do not need the RelatedClass elements. and are not class elements. They are multi-valued property elements. The PropertyMaps that use
      Message 2 of 4 , Nov 23, 2002
      • 0 Attachment
        1) You do not need the RelatedClass elements. <mattext> and <matimg> are
        not class elements. They are multi-valued property elements. The
        PropertyMaps that use property tables handle them.

        2) XML-DBMS does not allow you to store order information in a separate
        table. It must be in the same table as the data. Therefore, you need to:

        a) Delete the table mattex_matimg_order_table table.

        b) Add the item_order column to the mattext and matimg tables:

        create table mattext_table(
        mattext_id serial primary key,
        material_id int4,
        mattext_data varchar(255),
        item_order int4,
        CONSTRAINT mattext_material_fk FOREIGN KEY (material_id)
        REFERENCES material_table (material_id)
        )WITH OIDS;

        create table matimg_table(
        matimg_id serial primary key,
        material_id int4,
        matimg_data varchar(255),
        item_order int4,
        CONSTRAINT matimg_material_fk FOREIGN KEY (material_id)
        REFERENCES material_table (material_id)
        )WITH OIDS;

        c) Use the OrderColumn element in the PropertyMaps for <mattext> and
        <matimg>. For example, the map for mattext is:

        <PropertyMap>
        <ElementType Name="mattext"/>
        <ToPropertyTable Name="mattext_table"
        KeyInParentTable="Unique">
        <UseUniqueKey Name="PrimaryKey"/>
        <UseForeignKey Name="mattext_material_fk"/>
        </ToPropertyTable>
        <ToColumn Name="mattext_data"/>
        <OrderColumn Name="item_order" Generate="Yes" />
        </PropertyMap>

        d) Also, the ToColumn element must be after the ToPropertyTable element,
        not inside it. (The map compiler does not check for validation errors
        like this. You should turn on validation while you are developing maps.)

        -- Ron

        greeley304 wrote:
        >
        > Hi, my map problem have the map element problem again. I have to
        > generate the order of the mattext and matimg element, so i wrote a
        > order table to generate the order.
        > Here is my work:
        > sql:
        > create table material_table(
        > material_id serial primary key,
        > id int4
        > )WITH OIDS;
        >
        > create table mattext_table(
        > mattext_id serial primary key,
        > material_id int4,
        > mattext_data varchar(255),
        > CONSTRAINT mattext_material_fk FOREIGN KEY (material_id)
        > REFERENCES material_table (material_id)
        > )WITH OIDS;
        >
        > create table matimg_table(
        > matimg_id serial primary key,
        > material_id int4,
        > matimg_data varchar(255),
        > CONSTRAINT matimg_material_fk FOREIGN KEY (material_id)
        > REFERENCES material_table (material_id)
        > )WITH OIDS;
        >
        > create table mattex_matimg_order_table(
        > order_id serial primary key,
        > mattext_id int4,
        > matimg_id int4,
        > material_id int4,
        > item_order int4,
        > CONSTRAINT order_mattext_fk FOREIGN KEY (mattext_id)
        > REFERENCES mattext_table (mattext_id),
        > CONSTRAINT order_matimg_fk FOREIGN KEY (matimg_id)
        > REFERENCES matimg_table (matimg_id),
        > CONSTRAINT order_material_fk FOREIGN KEY (material_id)
        > REFERENCES material_table (material_id)
        > )WITH OIDS;
        > xml:
        > <?xml version="1.0" encoding="UTF-8"?>
        > <root>
        > <material id="11">
        > <mattext>Size</mattext>
        > <matimg>link1</matimg>
        > </material>
        > <material id="22">
        > <mattext>Pics</mattext>
        > <matimg>link2</matimg>
        > <mattext>link3</mattext>
        > </material>
        > </root>
        > map:
        > <Maps>
        > <ClassMap>
        > <ElementType Name="material"/>
        > <ToClassTable Name="material_table"/>
        > <PropertyMap>
        > <Attribute Name="id"/>
        > <ToColumn Name="id"/>
        > </PropertyMap>
        > <PropertyMap>
        > <ElementType Name="mattext"/>
        > <ToPropertyTable Name="mattext_table"
        > KeyInParentTable="Unique">
        > <UseUniqueKey Name="PrimaryKey"/>
        > <UseForeignKey Name="mattext_material_fk"/>
        > <ToColumn Name="mattext_data"/>
        > </ToPropertyTable>
        > </PropertyMap>
        > <PropertyMap>
        > <ElementType Name="matimg"/>
        > <ToPropertyTable Name="matimg_table"
        > KeyInParentTable="Unique">
        > <UseUniqueKey Name="PrimaryKey"/>
        > <UseForeignKey Name="matimg_material_fk"/>
        > </ToPropertyTable>
        > <ToColumn Name="matimg_data"/>
        > </PropertyMap>
        > <RelatedClass KeyInParentTable="Unique">
        > <ElementType Name="mattext"/>
        > <UseUniqueKey Name="PrimaryKey"/>
        > <UseForeignKey Name="order_mattext_fk"/>
        > </RelatedClass>
        > <RelatedClass KeyInParentTable="Unique">
        > <ElementType Name="matimg"/>
        > <UseUniqueKey Name="PrimaryKey"/>
        > <UseForeignKey Name="order_matimg_fk"/>
        > </RelatedClass>
        > <RelatedClass KeyInParentTable="Unique">
        > <ElementType Name="material"/>
        > <UseUniqueKey Name="PrimaryKey"/>
        > <UseForeignKey Name="order_material_fk"/>
        > <OrderColumn Name="item_order" Generate="Yes"/>
        > </RelatedClass>
        > </ClassMap>
        > </Maps>
        >
        > In the map file, i should use the mattext and matimg again in order
        > to write the relatedclass code for the foreign key. But i reuse the
        > same element. Is it any way i can use the element twice?
      • greeley304
        Hi,I have tried this before I tried the RelatedClass, what i got the item_order is invalid, for the following xml
        Message 3 of 4 , Nov 25, 2002
        • 0 Attachment
          Hi,I have tried this before I tried the RelatedClass, what i got the
          item_order is invalid, for the following xml
          <root>
          <material id="11">
          <mattext>Size</mattext>
          <matimg>link1</matimg>
          </material>
          <material id="22">
          <mattext>Pics</mattext>
          <matimg>link2</matimg>
          <mattext>link3</mattext>
          </material>
          </root>

          item_order for matimg will be 4,4
          for mattext will be 2,6,6

          that's why i'd like to try use different table to generate the order,
          thank u for help.

          --- In xml-dbms@y..., Ronald Bourret <rpbourret@r...> wrote:
          > 1) You do not need the RelatedClass elements. <mattext> and
          <matimg> are
          > not class elements. They are multi-valued property elements. The
          > PropertyMaps that use property tables handle them.
          >
          > 2) XML-DBMS does not allow you to store order information in a
          separate
          > table. It must be in the same table as the data. Therefore, you
          need to:
          >
          > a) Delete the table mattex_matimg_order_table table.
          >
          > b) Add the item_order column to the mattext and matimg tables:
          >
          > create table mattext_table(
          > mattext_id serial primary key,
          > material_id int4,
          > mattext_data varchar(255),
          > item_order int4,
          > CONSTRAINT mattext_material_fk FOREIGN KEY (material_id)
          > REFERENCES material_table (material_id)
          > )WITH OIDS;
          >
          > create table matimg_table(
          > matimg_id serial primary key,
          > material_id int4,
          > matimg_data varchar(255),
          > item_order int4,
          > CONSTRAINT matimg_material_fk FOREIGN KEY (material_id)
          > REFERENCES material_table (material_id)
          > )WITH OIDS;
          >
          > c) Use the OrderColumn element in the PropertyMaps for <mattext> and
          > <matimg>. For example, the map for mattext is:
          >
          > <PropertyMap>
          > <ElementType Name="mattext"/>
          > <ToPropertyTable Name="mattext_table"
          > KeyInParentTable="Unique">
          > <UseUniqueKey Name="PrimaryKey"/>
          > <UseForeignKey Name="mattext_material_fk"/>
          > </ToPropertyTable>
          > <ToColumn Name="mattext_data"/>
          > <OrderColumn Name="item_order" Generate="Yes" />
          > </PropertyMap>
          >
          > d) Also, the ToColumn element must be after the ToPropertyTable
          element,
          > not inside it. (The map compiler does not check for validation
          errors
          > like this. You should turn on validation while you are developing
          maps.)
          >
          > -- Ron
          >
          > greeley304 wrote:
          > >
          > > Hi, my map problem have the map element problem again. I have to
          > > generate the order of the mattext and matimg element, so i wrote a
          > > order table to generate the order.
          > > Here is my work:
          > > sql:
          > > create table material_table(
          > > material_id serial primary key,
          > > id int4
          > > )WITH OIDS;
          > >
          > > create table mattext_table(
          > > mattext_id serial primary key,
          > > material_id int4,
          > > mattext_data varchar(255),
          > > CONSTRAINT mattext_material_fk FOREIGN KEY (material_id)
          > > REFERENCES material_table (material_id)
          > > )WITH OIDS;
          > >
          > > create table matimg_table(
          > > matimg_id serial primary key,
          > > material_id int4,
          > > matimg_data varchar(255),
          > > CONSTRAINT matimg_material_fk FOREIGN KEY (material_id)
          > > REFERENCES material_table (material_id)
          > > )WITH OIDS;
          > >
          > > create table mattex_matimg_order_table(
          > > order_id serial primary key,
          > > mattext_id int4,
          > > matimg_id int4,
          > > material_id int4,
          > > item_order int4,
          > > CONSTRAINT order_mattext_fk FOREIGN KEY (mattext_id)
          > > REFERENCES mattext_table (mattext_id),
          > > CONSTRAINT order_matimg_fk FOREIGN KEY (matimg_id)
          > > REFERENCES matimg_table (matimg_id),
          > > CONSTRAINT order_material_fk FOREIGN KEY (material_id)
          > > REFERENCES material_table (material_id)
          > > )WITH OIDS;
          > > xml:
          > > <?xml version="1.0" encoding="UTF-8"?>
          > > <root>
          > > <material id="11">
          > > <mattext>Size</mattext>
          > > <matimg>link1</matimg>
          > > </material>
          > > <material id="22">
          > > <mattext>Pics</mattext>
          > > <matimg>link2</matimg>
          > > <mattext>link3</mattext>
          > > </material>
          > > </root>
          > > map:
          > > <Maps>
          > > <ClassMap>
          > > <ElementType Name="material"/>
          > > <ToClassTable Name="material_table"/>
          > > <PropertyMap>
          > > <Attribute Name="id"/>
          > > <ToColumn Name="id"/>
          > > </PropertyMap>
          > > <PropertyMap>
          > > <ElementType Name="mattext"/>
          > > <ToPropertyTable Name="mattext_table"
          > > KeyInParentTable="Unique">
          > > <UseUniqueKey Name="PrimaryKey"/>
          > > <UseForeignKey Name="mattext_material_fk"/>
          > > <ToColumn Name="mattext_data"/>
          > > </ToPropertyTable>
          > > </PropertyMap>
          > > <PropertyMap>
          > > <ElementType Name="matimg"/>
          > > <ToPropertyTable Name="matimg_table"
          > > KeyInParentTable="Unique">
          > > <UseUniqueKey Name="PrimaryKey"/>
          > > <UseForeignKey Name="matimg_material_fk"/>
          > > </ToPropertyTable>
          > > <ToColumn Name="matimg_data"/>
          > > </PropertyMap>
          > > <RelatedClass KeyInParentTable="Unique">
          > > <ElementType Name="mattext"/>
          > > <UseUniqueKey Name="PrimaryKey"/>
          > > <UseForeignKey Name="order_mattext_fk"/>
          > > </RelatedClass>
          > > <RelatedClass KeyInParentTable="Unique">
          > > <ElementType Name="matimg"/>
          > > <UseUniqueKey Name="PrimaryKey"/>
          > > <UseForeignKey Name="order_matimg_fk"/>
          > > </RelatedClass>
          > > <RelatedClass KeyInParentTable="Unique">
          > > <ElementType Name="material"/>
          > > <UseUniqueKey Name="PrimaryKey"/>
          > > <UseForeignKey Name="order_material_fk"/>
          > > <OrderColumn Name="item_order" Generate="Yes"/>
          > > </RelatedClass>
          > > </ClassMap>
          > > </Maps>
          > >
          > > In the map file, i should use the mattext and matimg again in
          order
          > > to write the relatedclass code for the foreign key. But i reuse
          the
          > > same element. Is it any way i can use the element twice?
        • Ronald Bourret
          I assume you mean the order was 2, 2, 6 for mattext. This is correct. The reason is that XML-DBMS does not know the DTD of your document. Therefore, it assumes
          Message 4 of 4 , Nov 26, 2002
          • 0 Attachment
            I assume you mean the order was 2, 2, 6 for mattext. This is correct.
            The reason is that XML-DBMS does not know the DTD of your document.
            Therefore, it assumes that PCDATA is significant. Between each of your
            elements, you have PCDATA in the form of a carriage return and a number
            of spaces. These are not stored in the database because you do not map
            them in your map file. However, XML-DBMS does count them when it is
            calculating order. This does not cause a problem when retrieving data
            because the code cares only about the order of the order values, not
            their absolute values.

            -- Ron

            greeley304 wrote:
            >
            > Hi,I have tried this before I tried the RelatedClass, what i got the
            > item_order is invalid, for the following xml
            > <root>
            > <material id="11">
            > <mattext>Size</mattext>
            > <matimg>link1</matimg>
            > </material>
            > <material id="22">
            > <mattext>Pics</mattext>
            > <matimg>link2</matimg>
            > <mattext>link3</mattext>
            > </material>
            > </root>
            >
            > item_order for matimg will be 4,4
            > for mattext will be 2,6,6
            >
            > that's why i'd like to try use different table to generate the order,
            > thank u for help.
            >
            > --- In xml-dbms@y..., Ronald Bourret <rpbourret@r...> wrote:
            > > 1) You do not need the RelatedClass elements. <mattext> and
            > <matimg> are
            > > not class elements. They are multi-valued property elements. The
            > > PropertyMaps that use property tables handle them.
            > >
            > > 2) XML-DBMS does not allow you to store order information in a
            > separate
            > > table. It must be in the same table as the data. Therefore, you
            > need to:
            > >
            > > a) Delete the table mattex_matimg_order_table table.
            > >
            > > b) Add the item_order column to the mattext and matimg tables:
            > >
            > > create table mattext_table(
            > > mattext_id serial primary key,
            > > material_id int4,
            > > mattext_data varchar(255),
            > > item_order int4,
            > > CONSTRAINT mattext_material_fk FOREIGN KEY (material_id)
            > > REFERENCES material_table (material_id)
            > > )WITH OIDS;
            > >
            > > create table matimg_table(
            > > matimg_id serial primary key,
            > > material_id int4,
            > > matimg_data varchar(255),
            > > item_order int4,
            > > CONSTRAINT matimg_material_fk FOREIGN KEY (material_id)
            > > REFERENCES material_table (material_id)
            > > )WITH OIDS;
            > >
            > > c) Use the OrderColumn element in the PropertyMaps for <mattext> and
            > > <matimg>. For example, the map for mattext is:
            > >
            > > <PropertyMap>
            > > <ElementType Name="mattext"/>
            > > <ToPropertyTable Name="mattext_table"
            > > KeyInParentTable="Unique">
            > > <UseUniqueKey Name="PrimaryKey"/>
            > > <UseForeignKey Name="mattext_material_fk"/>
            > > </ToPropertyTable>
            > > <ToColumn Name="mattext_data"/>
            > > <OrderColumn Name="item_order" Generate="Yes" />
            > > </PropertyMap>
            > >
            > > d) Also, the ToColumn element must be after the ToPropertyTable
            > element,
            > > not inside it. (The map compiler does not check for validation
            > errors
            > > like this. You should turn on validation while you are developing
            > maps.)
            > >
            > > -- Ron
            > >
            > > greeley304 wrote:
            > > >
            > > > Hi, my map problem have the map element problem again. I have to
            > > > generate the order of the mattext and matimg element, so i wrote a
            > > > order table to generate the order.
            > > > Here is my work:
            > > > sql:
            > > > create table material_table(
            > > > material_id serial primary key,
            > > > id int4
            > > > )WITH OIDS;
            > > >
            > > > create table mattext_table(
            > > > mattext_id serial primary key,
            > > > material_id int4,
            > > > mattext_data varchar(255),
            > > > CONSTRAINT mattext_material_fk FOREIGN KEY (material_id)
            > > > REFERENCES material_table (material_id)
            > > > )WITH OIDS;
            > > >
            > > > create table matimg_table(
            > > > matimg_id serial primary key,
            > > > material_id int4,
            > > > matimg_data varchar(255),
            > > > CONSTRAINT matimg_material_fk FOREIGN KEY (material_id)
            > > > REFERENCES material_table (material_id)
            > > > )WITH OIDS;
            > > >
            > > > create table mattex_matimg_order_table(
            > > > order_id serial primary key,
            > > > mattext_id int4,
            > > > matimg_id int4,
            > > > material_id int4,
            > > > item_order int4,
            > > > CONSTRAINT order_mattext_fk FOREIGN KEY (mattext_id)
            > > > REFERENCES mattext_table (mattext_id),
            > > > CONSTRAINT order_matimg_fk FOREIGN KEY (matimg_id)
            > > > REFERENCES matimg_table (matimg_id),
            > > > CONSTRAINT order_material_fk FOREIGN KEY (material_id)
            > > > REFERENCES material_table (material_id)
            > > > )WITH OIDS;
            > > > xml:
            > > > <?xml version="1.0" encoding="UTF-8"?>
            > > > <root>
            > > > <material id="11">
            > > > <mattext>Size</mattext>
            > > > <matimg>link1</matimg>
            > > > </material>
            > > > <material id="22">
            > > > <mattext>Pics</mattext>
            > > > <matimg>link2</matimg>
            > > > <mattext>link3</mattext>
            > > > </material>
            > > > </root>
            > > > map:
            > > > <Maps>
            > > > <ClassMap>
            > > > <ElementType Name="material"/>
            > > > <ToClassTable Name="material_table"/>
            > > > <PropertyMap>
            > > > <Attribute Name="id"/>
            > > > <ToColumn Name="id"/>
            > > > </PropertyMap>
            > > > <PropertyMap>
            > > > <ElementType Name="mattext"/>
            > > > <ToPropertyTable Name="mattext_table"
            > > > KeyInParentTable="Unique">
            > > > <UseUniqueKey Name="PrimaryKey"/>
            > > > <UseForeignKey Name="mattext_material_fk"/>
            > > > <ToColumn Name="mattext_data"/>
            > > > </ToPropertyTable>
            > > > </PropertyMap>
            > > > <PropertyMap>
            > > > <ElementType Name="matimg"/>
            > > > <ToPropertyTable Name="matimg_table"
            > > > KeyInParentTable="Unique">
            > > > <UseUniqueKey Name="PrimaryKey"/>
            > > > <UseForeignKey Name="matimg_material_fk"/>
            > > > </ToPropertyTable>
            > > > <ToColumn Name="matimg_data"/>
            > > > </PropertyMap>
            > > > <RelatedClass KeyInParentTable="Unique">
            > > > <ElementType Name="mattext"/>
            > > > <UseUniqueKey Name="PrimaryKey"/>
            > > > <UseForeignKey Name="order_mattext_fk"/>
            > > > </RelatedClass>
            > > > <RelatedClass KeyInParentTable="Unique">
            > > > <ElementType Name="matimg"/>
            > > > <UseUniqueKey Name="PrimaryKey"/>
            > > > <UseForeignKey Name="order_matimg_fk"/>
            > > > </RelatedClass>
            > > > <RelatedClass KeyInParentTable="Unique">
            > > > <ElementType Name="material"/>
            > > > <UseUniqueKey Name="PrimaryKey"/>
            > > > <UseForeignKey Name="order_material_fk"/>
            > > > <OrderColumn Name="item_order" Generate="Yes"/>
            > > > </RelatedClass>
            > > > </ClassMap>
            > > > </Maps>
            > > >
            > > > In the map file, i should use the mattext and matimg again in
            > order
            > > > to write the relatedclass code for the foreign key. But i reuse
            > the
            > > > same element. Is it any way i can use the element twice?
            >
            >
            > To post a message, send it to: xml-dbms@yahoogroups.com
            > To unsubscribe, send a blank message to: xml-dbms-unsubscribe@yahoogroups.com
            > Or join the newsgroup at: news://news.barkto.com/homeless.xml.xml-dbms
            >
            > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

            --
            Ronald Bourret
            Programming, Writing, and Research
            XML, Databases, and Schemas
            http://www.rpbourret.com
          Your message has been successfully submitted and would be delivered to recipients shortly.