SIR R becomes consequently more advantageous
than SR R and C-view R for the avoidance of the
logical navigation or of selected value expressions.
In what follows, we qualify of explicit, every IE
with the above sub-list. We denote it as E or E
R
for
SIR R. Observe that while these IAs are always
contiguous in E
R
, they may be separated by SAs in
Create Table R, we recall.
Ex. 1. Recall the ‘biblical’ Supplier-Part DB,
often named S-P in short, modelling some suppliers,
parts and supplies. Every supply contains some
quantity of a part shipped by some supplier. A
supplier may supply nothing for the time being.
Likewise, a part may be not supplied. S-P motivated
the original proposal of the relational model, [C69],
[C70]. Variants settled the relational (conceptual
schema) design rules of SRV-model, based on NFs
as known. Through these rules, S-P molded about
every practical DB. The variant we pick up below
seems best known, (Date, 2004) . We refer to it as S-
P1. We restate S-P1 into variants with different
SIRs. We call S-P2 the variant that follows.
S-P1 has three well-known relations: S (S#,
SNAME, STATUS, CITY), P (P#, PNAME,
COLOR, WEIGHT, CITY), SP (S#, P#, QTY).
Figure 1 shows the original sample data type for
every attribute. Actually, the figure shows S-P2 DB.
S-P1.S and P are the same SRs as in S-P2. For S-
P1.SP, data types are these of S-P2.SP at the figure.
The latter is however SIR SP that we present it in
detail soon. All the SA definitions at the figure skip
some practical details, e.g., the data length. We
underline the primary key, as usual.
Figure 2 shows the original sample data values
for S-P1. For S-P1.SP, these are among those of SIR
SP there, according to the attribute names. For the
relational algebra, considered by the original S-P1
proposal, the order of attributes in a relation, hence
the left-to-right one at the figures does not matter.
As known, it does for SQL, e.g., for Select * From
SP. The S-P1 scheme is the optimal one, in the sense
of having the minimal number of SRs free of
normalization anomalies, (Date, 2012) .
The notorious drawback of S-P1 is that practical
Select queries to SP usually need values from S or P
as well. E.g., most actual clients searching for a
supply need the supplier or part name(s). These are
evidently conceptual attributes of every supply.
However they are not in SP, since the notorious
normalization anomaly would make SP losing its
BCNF form (in fact, SP is in 5
Th
form even). Every
related query has then to logically navigate over SP
and S or P or both through inter-relational joins
SP.S# = S.S# or SP.P# = P.P#. One knows well that
clients usually hate the logical navigation, feeling it
making the queries more procedural than they
should be, (Maier, 1984). The well-know “escape
route” for S-P1 is adding the (universal) view,
named view SP, providing the image of SP with
every tuple preserved bijectively and expanded with
every matching value of every attribute of S and of P
or with nulls otherwise. Such a view avoids the
logical navigation to more queries than any other
view of SP with fewer attributes or values. To create
view SP, one has to rename first SR SP, to, say, SP_,
since every relation in an SQL DB must have a
different name. Then, likely the least procedural
view SP declaration in SQL is as follows, provided
the removal of all the spaces added for easier
readability only, e.g., after each comma:
(1) Create View SP As (Select SP_.*,
SNAME, STATUS, S.CITY, PNAME, COLOR,
WEIGHT, P.CITY From (SP_ Left Join S On
SP_.S# = S.S#) Left Join P On SP_.P# =
P.P#);
Unlike for the original SR SP, the SQL
formulation of a typical query to SP, such as name
of the supplier, quantity supplied and name of the
part for every supply with supplier Id ‘S1’, does not
need the logical navigation. The query becomes
notably less procedural, as one may easily verify.
To have a DB, say S-P2, with S, P and SIR SP,
instead of S-P1 with S, P and SP renamed to SP_,
and view SP defined by (1), one should figure out
first whether the view qualifies as C-view SP. This
is the case. First, view SP inherits bijectively every
tuple of SP_ as exactly one sub-tuple and has no
other tuples. In particular, (SP_.S#, SP_.P#) is the
primary key of SP_ and (SP.S#, SP.P#) is the one of
view SP. The rationale for all these properties is that
S.S# and P.P# are also the keys for S and P,
respectively. Accordingly, for the first tuple of SP_
at Figure 2 for instance, i.e., with SAs S# = S1 and
P# = P1, the join clauses match only one source
tuple in S and only one in P. Only a single tuple in
view SP results from that is the first one at the
figure. Similarly for SAs S# = S1 and P# = P2 etc.
View SP qualifying thus as C-view SP, we can
define SIR SP as above discussed through the
following Create Table SP:
(2) Create Table SP (S# Char, P# Char,
Qty Int, SNAME, STATUS, S.CITY, PNAME,
COLOR, WEIGHT, P.CITY From (SP_ Left
Join S On SP_.S# = S.S#) Left Join P On
SP_.P# = P.P#), Primary Key (S#, P#));
Figure 1 shows S-P2 scheme. Figure 2 shows the
content of SIR SP that would result for the sample
data of S-P1. Every SA is in plain text and every IA
in Italics. We suppose the SAs schemes in S-P2.SP