DBMS - (10) sub-query[where]: in, exists, all, any
DBMS - (10) subquery : in, exist, all, any Q1) cs major에 지원한 학생들의 sID, sName select sID, sName from Student where sID in (select sID from Apply where major = 'cs'); 'in' keyword를 사용하여 sub-query를 구현한 모습이다. select sID from Apply where major = 'cs'를 통해 Apply instance에서 cs에 지원한 sID를 relation으로 반환하고, 반환된 relation에 속한 sID만을 대상 상위 query가 실행된다. Q2) select [disticnt] sID, sName from Student, Apply where ..
DBMS - (9) The Basic SELECT Statement
DBMS - (9) The Basic SELECT Statement The Basic SELECT Statement - 1,2,3 순서로 어떤 SQL을 작성 할지 생각하면 된다. select A1,A2,...,An (3) what to return from R1,R2,...,Rm (1) relations where condition (2) combine filter Relational algebra of SELECT - π(A1,A2,...,An)σ(condition)(R1XR2,...,XRm) Example College(cName, state, enrollment) Student(sID, sName, GPA, size of HS) Apply(sID, cName, major, decision) Q1) ..
DBMS - (7) Relational Algebra - set operator, renaming
DBMS - (7) Relational Algebra - set operator, renaming Relational algebra query(expression) on set of relations produces relation as a result. Example College(cName, state, enrollment) Student(sID, sName, GPA, size of HS) Apply(sID, cName, major, decision) Union operator (1) List of college and student name Example, Stanford Susan Cornell ... - π(sName)(Student) U π(cName)(College) - but, All of..
DBMS - (6) Relational Algebra - select, project, join
DBMS - (6) Relational Algebra - select, project, join Query(expression) on set of relations produces relation as a result. Example College(cName, state, enrollment) Student(sID, sName, GPA, size of HS) Apply(sID, cName, major, decision) Select operator : picks certain rows (1) Students with GPA>3.7 - σ(GPA>3.7)(Student) (2) Students with GPA>3.7 and HS3.7^HS select operator is σ(condition)(Relat..