본문 바로가기

데이터베이스

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 - (8) Introduction to SQL DBMS - (8) Introduction to SQL SQL의 특성 SQL or 'sequel' Supported by all major commercial database systems. Standardized - many new features over time Interactive via GUI or prompt, or embedded in programs. Declarative, based on relational algebra query optimizer - It takes a query written in a SQL language. - It figures out the best way, the fastest way to execute that on the database DDL(Data D..
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..
DBMS - (5) JSON(JavaScript Object Notation) DBMS - (5) JSON(JavaScript Object Notation) Javascript Object Notation(JSON) 특성 - Standrad for 'serializing' data objects, usually in files - Human-readable, useful for data interchange - Also useful for representing & storing semi-structured data - No longer tied to JavaScript - Parsers for many languages. Basic constructs(recursive) - Base values : numbers, string, boolean, etc... - Object {} ..
DBMS - (4) XML(Extensible Markup Language) DBMS - (4) XML(Extensible Markup Language) structuring data의 한 방법으로서 relation model외의 또 다른 방법, XML Extensible Markup Language(XML) - Standard for data representation and exchange - Document format similar to HTML - Also streaming format - nested구조에서 개수의 제한이 없음(flexible) XML Basic constructus (1) Tagged elements(nested) (2) Attributes (3) Text Relation Model XML Structure Tables Hierarchical tree..
DBMS - (3) Querying Relational Databases DBMS - (3) Querying Relational Databases Steps in creating and using a RDBMS (1) Design schema; create using DDL (2) 'Bulk load' initial data (3) Repeat: execute queries and modifications Queires in high-level language - All students with GPA > 3.7 applying to Stanford and MIT only. - All engineering department in CA with 3.7 applying to stanford Relational algebra π(ID)σ(GPA>3.7)^Apply.college=..