SMWP - Fragment Class
 

Index

Introduction
Differences
Installation I
Installation II
Installation III
Uninstall

Working with SMWP

Parameter
Fragement Class
Page Class
XML Document (Page)



4.8 Create Fragment Class

4.8.1 Create Primary Fragment Class

Syntax

"CREATE PRIMARY FRAGMENT CLASS" className
"FRAGMENTATION BASE CLASS" className
["FRAGMENT SELECTION PREDICATE" "[" fragmentPredicate "]" ]
["TUPLE SELECTION PREDICATE" "[" tuplePredicate "]" ]
["PUBLISH FRAGMENT AS NAME" fragmentElementName
"AND TUPLE AS NAME" tupleElementName
"IN NAMESPACE [" nsURI "];"

A primary fragment class is defined upon a fragment base class. The primary fragment class inherits all parameters introduced by the fragment base class and allows the primary fragment class to introduce one new parameter. Selection predicates allow to narrow the set of fragments taken over from the fragment base class. The FRAGMENT SELECTION PREDICATE limits the fragments inserted into the fragmentation relation. It is specified as SQL expression and refers only parameters of the primary fragment class. The TUPLE SELECTION PREDICATE limits the set of tuples in fragments that are taken over. Specified as SQL expression it refers only tuple attributes which are not used as parameters.

Preconditions

  • If the introduced parameter is a predicate parameter the parameter name must not match a column name from the the fragment class relation (name conflict).
  • The introduced parameter must by defined upon a root fragment class of the base fragment class. Root fragment class and base fragment class may be identical.
  • The primary fragment class inherits all parameters from its base fragment class and must add exactly one parameter.

Figure 8: Create primary fragment class - Schema

The publication information provided by the "PUBLISH FRAGMENT AS ..." part of the create statement is used to transform the fragments of the primary fragment class into an XML document. The whole fragment is inserted as XML-Element by the name fragmentName. The tuples of the fragments are inserted as XML elements named tupleName. In order to provide qualified element names the Namespace ns_uri is used (see 4.16 Structure of generated XML ).

Example 10

CREATE PRIMARY FRAGMENT CLASS wineries<region>
FRAGMENTATION BASE CLASS wineries<>
FRAGMENT SELECTION PREDICATE [region!='wels']
TUPLE SELECTION PREDICATE [category='premium']
PUBLISH FRAGMENT AS NAME all_wineries_by_region
AND TUPLE AS NAME winery
IN NAMESPACE [http://dke.uni-linz.ac.at/smwp/winery];


This statement creates the primary fragment class wineries<region> which is based on the fragment base class wineries<>. The primary fragment class contains all attributes from its fragment base class. The TUPLE SELECTION PREDICATE allows only tuples from the fragment class relation which fulfill category='premium'. The creation of the fragment with the parameter value 'wels' is prevented by the FRAGMENT SELECTION PREDICATE.

Figure 9: Primary Fragment Class introducing Value Parameter

If the created fragment class is being mapped to a page class its publication information is being used. The fragment class wil be inserted into the xml document using the element name all_wineries_by_region in the namespace http://dke.uni-linz.ac.at/smwp/winery. The fragment class tuples are inserted by the element name winery. The generated fragment class element from the XML document displays itself in the following way:

<all_wineries_by_region	
xmlns="http://dke.uni-linz.ac.at/smwp/winery"
xmlns:smwp="http://dke.uni-linz.ac.at/smwp/1.0"
smwp:fragmentClass="wineries_region"
smwp:params="region"
fc_paramName="chia">
<winery smwp:id="rowid">
<address>-</address>
<category>premium</category>
<descr>-</descr>
<id>1</id>
<name>Calliterra</name>
<region>chia</region>
</winery>
<winery> … <winery>
</all_wineries_by_region>

Table 4: XML-Element for Fragment Class

The resulting XML documents are discussed in 4.16 Structure of generated XML .

Example 11

CREATE PRIMARY FRAGMENT CLASS rankings<rcateg>
FRAGMENTATION BASE CLASS rankings<>
FRAGMENT SELECTION PREDICATE [rcateg!=other];

Creates primary fragment class rankings<rcateg> which introduces the predicate based parameter rcateg (see 4.4.3 Create Predicate Parameter). Following relations will be created for the new primary fragment class: FR_RANKINGS_RCATEG (fragmentation relation) and RANKINGS_RCATEG (fragment class relation). The fragment class relation obtains a new column RCATEG. Every tuple of the fragment base class relation is tested against the predicateValue of the predicate parameter. If it matches, the tuple will be inserted into the primary fragment class relation containing the predicateLabel as value for attribute rCateg.
The created primary fragment class can be used as fragment base class for any 0further fragmentation without checking which parameter type was used.

Figure 10: Primary Fragment Class introducing Predicate Parameter

4.8.2 Create Derived Fragment Class

Syntax

"CREATE DERIVED FRAGMENT CLASS" className
"FRAGMENTATION BASE CLASS" classNameFragBase "AS" aliasNameFragBase
"DERIVATION BASE CLASS" classNameDerivBase "AS" aliasNameDerivBase
"JOIN BY [" sqlStatement "]"
[ "PUBLISH FRAGMENT AS NAME" fragmentElementName
"AND TUPLE AS NAME" tupleElementName
"IN NAMESPACE [" nsURI "]" ]
";"

A derived fragment class is defined upon a fragment base class and a derivation base class. The tuples are taken from fragment base class and are further partitioned according to the fragmentation parameters of the derivation base class. The fragment base class may be fragmented by several parameters or may be unfragmented as well. The derivation base class must possess exactly one parameter (which is a limitation of this prototype). The create statement for a derived fragment class provides alias names for fragment base class and derivation base class which are used in the JOIN BY part of the statement.

Preconditions:

  • the derivation base class must be partitioned by one parameter

Example 12

CREATE DERIVED FRAGMENT CLASS wines<region>
FRAGMENTATION BASE CLASS wineries<region> AS winery
DERIVATION BASE CLASS wines<> AS wine
JOIN BY [winery.id = wine.producedby]
PUBLISH FRAGMENT AS all_wines_by_region
AND TUPLE AS NAME wine
IN NAMESPACE [http://dke.uni-linz.ac.at/smwp/winery];

The derived fragment class wines<region> is being created upon fragment base class wines<> and derivation base class wineries<region>. The root fragment class wines<> will be further parameterized usind the parameter provided by wineries<region>. The derived fragment class comprises several fragments, each containg wines that were produced in the resepctive region by a winery (e.g., wines<chia> contains wines that were produced in Chianti).

Figure 11: Create Derived Fragment Class

4.9 Edit Fragment Class

Syntax

"ALTER FRAGMENT CLASS" className
("TO PUBLISH FRAGMENT AS" fragmentElementName
"AND TUPLE AS NAME" tupleElementName
"IN NAMESPACE [" nsURI "]"
| "CLEAR PUBLICATION SPECIFICATION" ) ";"

Editing fragment classes is only available for adding, modifying and deleting xml publishing information. If it is necessary to modify a fragment class simply delete and re-create it. Fragment classes can not be published as XML document without publication specification. Fragment classes without publication information can be mapped to page classes, but they will not be displayed in the resulting XML documents. Adding, modifying or deleting the publication spezification from an fragment class mapped to a page class results in regeneration of all XML documents whose source is a page class the fragment class is mapped to.

Example 13

ALTER FRAGMENT CLASS wineries<region>
TO PUBLISH FRAGMENT AS all_wines_by_region
AND TUPLE AS NAME wine
IN NAMESPACE [http://dke.uni-linz.ac.at/smwp/winery];

Adds publication information to the fragment class wineries<region>. If the fragment class is already equiped with publication specification, the specification will be changed.

Example 14

ALTER FRAGMENT CLASS wineries<region>
CLEAR PUBLICATION SPECIFICATION;

Removes all publication specification from the fragment class wineries<region>.

4.10 Delete Fragment Class

Syntax

"DROP FRAGMENT CLASS" className";"

Deletes the fragment class designated by className. This statement deletes the fragment class relation and its corresponding fragmentation relation. If the fragment class is a root fragment class its fragmentation relation (which is also an application relation) will not be deleted. Root fragment classes also do not contain fragmentation relations.

Preconditions

  • fragment class not mapped to page class
  • fragment class not used as base class by another fragment class

Example 15

DROP FRAGMENT CLASS wineries<region>;

Deletes the fragment class wineries<region> which is not mapped to a page class and not used as fragment base class by another fragment class. The fragment class relation wineries_region and its corresponding fragmentation relation fr_wineries_region will be deleted.

4.11 Display Fragment Class

Syntax

"SHOW FRAGMENT CLASS" (className | * ) ";"

Using this statement works for two options. Either displaying a list of all generated fragment classes, or displaying information about one specific fragment class. The list of all created fragment classes shows their names, their types (either primary, derived or root fragment class) and if they contain publication specifications. The detail information about one fragment class contains its base classes, selection predicates, publication specifications and its parameters.

Example 16

SHOW FRAGMENT CLASS *;

Displays the names of all created fragment classes including their type (primary fragment class, derived fragment class or root fragment class) and their publication information. Information is shown if the fragment class is mapped to any page class.


Figure 12: Display list of Fragment Classes

Example 17

SHOW FRAGMENT CLASS wineries<region>;

Displays all metadata gathered about the given fragment class. The information shows that wineries<region> is a primary fragment class defined upon fragment base class wineries<>. The fragment class contains publishing information and is being used as foundation fragment class for page class wines<region>.


Figure 13: Display Fragment Class wineries<region>