So I have this assignment in which I need to use Selection and Projection operators on n-ary relations.

The book really doesn't cover it in a way I understand and doesn't explain it in terms of c++, so could someone help me out. Could someone give me a "c++ code explanation" on what these are?

Thanks.

Not real sure what a "Projection" operator is, but your "Selection" operators are the "dot" and "arrow" operators ('.' and '->' respectively). They are used to access the elements of an object.

An example class:

class example {
public:
  example(int newInt = 0) : aPublicInt(newInt) {} //default constructor
  int anIntMember;
};
//others can argue about the security on anIntMember,
//the question is about operators, not class design

The "dot" operator is used to select a member when you are operating on an actual instance of an object.

//declare an object
example anExampleObj(5);

//use the "dot" operator to access example::anIntMember
cout << "The value of anIntMember is: " << anExampleObj.anIntMember << endl;

The "arrow" operator is used to select a member when you are operating on a pointer to an instance of an object.

//declare an object pointer and allocate an object
example *anExamplePtr = new example(5);

//use the "arrow" operator to access example::anIntMember
cout << "The value of anIntMember is: " << anExamplePtr->anIntMember << endl;

//release the pointed object
delete anExamplePtr;

Never heard of them either. But after reading this I tink its nothing more than the WHERE clause in SQL statements. SELECT Name,Office,Dep,Rank FROM mytable WHERE dep = 'CS'; That is an SQL example select statement. Put quotes around it, make it a string, then send it to an SQL compliant database, such as MySQL. std::string = "SELECT Name,Office,Dep,Rank FROM mytable WHERE dep = 'CS'"; For more complex examples you need to understand unions and sets.

This all has to do with SQL (Structured Query Language) and databases, not c++, although you can use c++ to access SQL compliant databases.

Ah. Now I sorta see what needs to be done. I never realized I needed an sqlapi library for this, and those WHERE clauses help.

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.