Page 133 - C++
P. 133
TOYS t;
while( if1.read((char *)&a, sizeof(a)))
{
if( strcmp( “5 to 8”, t.whatage())==0)
a.display();
}
If1.close();
}
5. a) Explain the concept of Cartesian product of two tables, with the help of
appropriate example. 2
Ans: It is called unrestricted join. It gives all possible combinations of records of both tables.
If table 1 contains 3 records and table 2 contains 2 records then Cartesian product will be
6 records.
Table 1 Table 2
Admno Name classsec Admno Eng Maths Sc
111 Abhinash 3E 222 98 99 88
222 Arundeep 7B 111 90 100 99
333 Aman 10E
Then Cartesian product will be:
Admno Name Classsec Admno Eng Maths Sc
111 Abhinash 3E 222 98 99 88
111 Abhinash 3E 111 90 100 99
222 Arundeep 7B 222 98 99 88
222 Arundeep 7B 111 90 100 99
333 Aman 10E 222 98 99 88
333 Aman 10E 111 90 100 99
b) Consider the following tables PRODUCTS and SUPPLIERS and answer
(b1) and (b2) parts of the question:
Table: PRODUCTS
PID PNAME SUPCODE QTY PRICE COMPANY
101 DIGITAL CAMERA S01 120 12000 CREATIVE
102 DIGITAL PAD S02 100 22000 iBALL
104 PENDRIVE 16GB S01 500 1100 KINGSTON
106 LED SCREEN 32” S02 70 28000 SAMSUNG
XII / Comp. Sc. Page 12 of 17