Second day writting

Second day writting

by Mingyuan Gao -
Number of replies: 0

From today’s video, I learned about the relational algebra, and I want to talk about the simple way to use the Select Operator and the Project Operator, which is very funny. At the beginning, the Select Operator is use to pick a certain row of the relations, for example, we set three relations: college, student, and apply to the college. The college we have some information like Cname which is college name, and state where the college located, and enrollment of the college. The student we have sID which is ID of student, sName which is student’s name, GPA, and HS: the size of high school that the student attended. The Apply we have sID which is similar to former one, Cname, major which is the student applied for, and decision which means the decision of the application. And if we want the whole relation of student we can just type in the word “student”, then we can get a table of student.

If we want a certain row of those relation, we need to use the Select Operator which is donated by a Greek symbol, sigma, it’s also written like σ. Right now, we want to find those students whose GPA are greater than 3.7, we can just write like σGPA > 3.7Student. And if we want to find the students whose GPA are greater than 3.7, and their high school size are less than 1000, we will write like σGPA > 3.7HS > 1000Student. And if we want to find the application for the Stanford university CS major, we should write like σcName = ‘Stanford’major = ‘CS’Apply. So, basically, the Select Operator should be written like σcondition Relation name.

If we want a certain column of relations, we should use the Project Operator, which is also written by a Greek symbol, pi, which looks like π. Then, if we want the students’ ID and decisions for all application, we can write like πsID, decision Apply. And basically, the Project Operator is like πattribute1, anyNum, attribute2 Relation.

Then, the last thing, if we just want some of rows and some of columns, for example, the students’ ID and the name of students with GPA > 3.7, we can write like πsID, sName GPA > 3.7Student).