Structured Query Language
Write a definition for function BUMPER( ) in C++ to read each object of a binary file GIFTS.DAT, find and display details of those gifts, which has remarks as “ÖN DISCOUNT”. Assume that the file GIFTS.DAT is created with the help of objects of class GIFTS, which is defined below:
class GIFTS
{
int ID;char Gift[20],Remarks[20]; float Price;
public:
void Takeonstock()
{
cin>>ID;gets(Gift);gets(Remarks);cin>>Price;
}
void See()
{
cout<<ID<<':'<<Gift<<':'<<Price<<':'<<Remarks<<endl;
}
char *GetRemarks(){return Remarks;}
}
void BUMPER()
{
GIFTS G;
ifstream fin;
fin.open(“GIFTS.DAT”, ios::binary);
while(fin.read((char*)&G, sizeof(G)))
{
if(strcmp(G.GetRemarks(), 'ON DISCOUNT')==0)
G.See();
}
fin.close();
}
Sponsor Area
Write a definition for function BUMPER( ) in C++ to read each object of a binary file GIFTS.DAT, find and display details of those gifts, which has remarks as “ÖN DISCOUNT”. Assume that the file GIFTS.DAT is created with the help of objects of class GIFTS, which is defined below:
class GIFTS
{
int ID;char Gift[20],Remarks[20]; float Price;
public:
void Takeonstock()
{
cin>>ID;gets(Gift);gets(Remarks);cin>>Price;
}
void See()
{
cout<<ID<<':'<<Gift<<':'<<Price<<':'<<Remarks<<endl;
}
char *GetRemarks(){return Remarks;}
}
Find the output of the following C++ code considering that the binary file MEM.DAT exists on the hard disk with a data of 1000 members.
class MEMBER
{
int Mcode;char MName[20];
public:
void Register();void Display();
};
void main()
{
fstream MFile;
MFile.open('MEM.DAT',ios::binary|ios::in);
MEMBER M;
MFile.read((char*)&M, sizeof(M));
cout<<'Rec:'<<MFile.tellg()/sizeof(M)<<endl;
MFile.read((char*)&M, sizeof(M));
MFile.read((char*)&M, sizeof(M));
cout<<'Rec:'<<MFile.tellg()/sizeof(M)<<endl;
MFile.close();
}
Give a suitable example of a table with sample data and illustrate Primary and Alternate Keys in it.
Consider the following tables CARDEN and CUSTOMER and answer (b) and (c) parts of question:
TABLE: CARDEN
Ccode |
CarName |
Make |
Color |
Capacity |
Charges |
501 |
A-Star |
Suzuki |
RED |
3 |
14 |
503 |
Indigo |
Tata |
SILVER |
3 |
12 |
502 |
Innova |
Toyota |
WHITE |
7 |
15 |
509 |
SX4 |
Suzuki |
SILVER |
4 |
14 |
TABLE: CUSTOMER
CCode |
Cname |
Ccode |
1001 |
Hemant Sahu |
501 |
1002 |
Raj Lal |
509 |
1002 |
Feroza Shah |
503 |
1004 |
Ketan Dhal |
502 |
Write SQL commands for the following statements:
Consider the following tables CARDEN and CUSTOMER and answer (b) and (c) parts of question:
TABLE: CARDEN
Ccode |
CarName |
Make |
Color |
Capacity |
Charges |
501 |
A-Star |
Suzuki |
RED |
3 |
14 |
503 |
Indigo |
Tata |
SILVER |
3 |
12 |
502 |
Innova |
Toyota |
WHITE |
7 |
15 |
509 |
SX4 |
Suzuki |
SILVER |
4 |
14 |
TABLE: CUSTOMER
CCode |
Cname |
Ccode |
1001 |
Hemant Sahu |
501 |
1002 |
Raj Lal |
509 |
1002 |
Feroza Shah |
503 |
1004 |
Ketan Dhal |
502 |
Give the output of the following SQL queries:
Sponsor Area
Sponsor Area