Consider the following bill of materials problem: the database has a relation Subpart(Part, Subpart, Quantity), which tells which direct subparts are needed for each part and in what quantity. For instance, Subpart(mounting_assembly, screw, 4) means that the mounting assembly includes four screws. For simplicity, let us assume that parts that do not have subparts (the atomic parts) are
represented as having NULL as the only subpart (for instance, Subpart(screw, NULL,0)). Write a recursive query to produce a list of all parts and for each part the number of primitive subparts it has.
What will be an ideal response?
CREATE RECURSIVE VIEW PartListCount(Part, PrimitiveCount) AS
SELECT S.Part, 1
FROM Subpart S
WHERE S.Subpart IS NULL
UNION
SELECT S.Part, SUM(S.Quantity * L.PrimitiveCount)
FROM Subpart S, PartListCount L
WHERE S.Subpart = L.Part
GROUP BY S.Part
The ?rst, non-recursive subquery starts the computation by producing the list of primitive parts and assigning 1 as the number of primitive components of each such part (the check IS NULL is intended to ensure that the part is primitive). The recursive
subquery then computes the total number of primitive components for parts that are composed of several subparts.
Computer Science & Information Technology
You might also like to view...
Several escape sequences, including the newline and horizontal tab escape sequences, are only recognized inside a container element such as the
element.Answer the following statement true (T) or false (F)
Computer Science & Information Technology
Describe an S-Video port.
What will be an ideal response?
Computer Science & Information Technology
If at all possible, avoid displaying your presentation from a(n) ________ drive
Fill in the blank(s) with correct word
Computer Science & Information Technology
A general linear list is a list in which operations can be done anywhere in the list.
Answer the following statement true (T) or false (F)
Computer Science & Information Technology