Exemplo n.º 1
0
void Relation::project(map<int, string>& variables)
{
	set<Tuple> newTuples;
	Scheme newScheme;
	Tuple t;

	for (auto& v : variables){
		newScheme.addAttribute(scheme.getAttributes().at(v.first));
	}

	for (auto& tup : tuples){
		for (auto& v : variables)
		{
			t.addAttValue(tup.at(v.first));
		}
		if (variables.size() > 0){
			newTuples.insert(t);
			t.clear();
		}
	}

	tuples = newTuples;
	scheme = newScheme;
	setName("project");
}
Exemplo n.º 2
0
void Relation::rename(map<int, string>& variables)
{
	Scheme newScheme;
	for (auto& v : variables){
		newScheme.addAttribute(v.second);
	}
	scheme = newScheme;
	setName("rename");
}