관계연산


관계대수 : 절차적 특징, what, how를 모두 명시,


일반 집합연산자 : 합집합, 교집합, 차집합, 카티션 프로덕트


합,교,카티션은 교환법칙이 성립한다. R과 S의 합집합 = S와 R의 합집합


차집합은 순서를 바꾸면 전혀 다른 결과가 나오기 때문에 성립하지 않음


SELECT a, b FROM R, S -> 카티션 프로덕트


R이 3행, S가 5행이면 15행이 출력되기 때문에 조인에 비해서 굉장히 효율이 안좋다.


SELECT R.a, S.b FROM R,S WHERE R.c = S.c; -> 조인


마찬가지의 경우에 5행 이하로 출력되기 때문에 카티션 프로덕트에 비해서 굉장히 효율이 좋다.


순수 관계연산자 : SELECT σ, PROJECT π, JOIN ⋈, DIVISION ÷


SELECT : 조건에 만족하는 행을 추출 -> 필요없는 행을 모두 삭제 -> 특정 컬럼을 검색


선택도(Selectivity)가 낮을때는 시그마를 먼저쓰는것이 효율이 좋다.


SQL에서 WHERE


PROJECT : 조건에 만족하는 열을 추출 -> 필요없는 열을 모두 삭제 -> 특정 튜플을 검색


SQL에서 SELECT


JOIN : 


DIVISION : 


관계해석 : 비절차적 특징, what만 명시,


튜플 관계 해석 : 1튜플 전체를 다 가져와서 필요한 속성을 골라 쓰는 방법


도메인 관계 해석 : 필요한 속성 일부만 변수로 잡아서 골라쓰는 방법



'프로그래밍 > ---DBMS---' 카테고리의 다른 글

정규화란?  (0) 2018.09.29
DB 용어 정리 DDL DML DCL TCL  (30) 2018.05.24


정규화



이상현상(삽입,삭제,정렬시)의 제거


릴레이션 분해


함수종속의 유지


완전함수 종속, 부분함수 종속, 이행함수 종속이 있다.


부분함수 종속을 해결하는것이 2정규화.


이행함수 종속을 해결하는것이 3정규화.


릴레이션의 모든 속성을 후보키로 만드는것을 보이스코드 정규화.


릴레이션에서 다치 종속 관계가 성립하는 경우 4정규화


릴레이션에서 조인 종속이 성립하는 경우 5정규화


릴레이션에서 이상 현상이 발생할 수 있는 함수 종속관계를 제거하기 위하여, 릴레이션을 분해하는 작업.


함수 종속 관계



X -> Y : Y는 X에 완전 함수적 종속 되어있다.


X : 결정자이자 기본키라고 한다.


Y : X의 종속자


한 테이블 내에서 기본키가 A, B(복합키)일때, C는 A, B에 종속 되어있으나, D는 B에만 종속되어 있을때, D를 부분함수 종속이라고 한다.


R(A,B,C,D)는 제2 정규화가 필요하다.


정규화 후에는 R1(A,B,C,) ,R2(B,D)로 나누어진다.


B는 R1의 외래키, R2의 기본키로 작동한다.



한 테이블 내에서 A->B, B->C일때 A->C를 결정할 수 있게 되면 이행함수 종속관계라고 한다.


R(A,B,C)는 제 3정규화가 필요하다.


정규화 후에는 R1(A,B), R2(B,C) 로 나눈다. 이유는, A가 B를 결정하는데 B가 외래키 이므로 A에 의해 C도 결정된다고 논리적으로 이해할 수 


있기 때문이다. R1(A,B) R2(A.C)는 이런 논리적인 연결이 불가능하므로 안된다.



학번->(성명,학과,학년) X->Y 의 예



기본키는 릴레이션의 속성명에 밑줄이 쳐져 있다.


'프로그래밍 > ---DBMS---' 카테고리의 다른 글

관계 데이터 연산  (0) 2018.09.29
DB 용어 정리 DDL DML DCL TCL  (30) 2018.05.24


DDL (Data Definition Language) :

Data Definition Language is used to define database structure or schema. DDL is also used to specify additional properties of the data. The storage structure and access methods used by the database system by a set of statements in a special type of DDL called a data storage and definition language. These statements defines the implementation details of the database schema, which are usually hidden from the users. The data values stored in the database must satisfy certain consistency constraints.
For example, suppose the university requires that the account balance of a department must never be negative. The DDL provides facilities to specify such constraints. The database system checks these constraints every time the database is updated. In general, a constraint can be arbitrary predicate pertaining to the database. However, arbitrary predicates may be costly to the test. Thus, database system implements integrity constraints that can be tested with minimal overhead.

  1. Domain Constraints : A domain of possible values must be associated with every attribute (for example, integer types, character types, date/time types). Declaring an attribute to be of a particular domain acts as the constraints on the values that it can take.
  2. Referential Integrity : There are cases where we wish to ensure that a value appears in one relation for a given set of attributes also appear in a certain set of attributes in another relation i.e. Referential Integrity. For example, the department listed for each course must be one that actually exists.
  3. Assertions : An assertion is any condition that the database must always satisfy. Domain constraints and Integrity constraints are special form of assertions.
  4. Authorization : We may want to differentiate among the users as far as the type of access they are permitted on various data values in database. These differentiation are expressed in terms of Authorization. The most common being :
    read authorization – which allows reading but not modification of data ;
    insert authorization – which allow insertion of new data but not modification of existing data
    update authorization – which allows modification, but not deletion.

DML (Data Manipulation Language) :

DML statements are used for managing data with in schema objects.
DML are of two types –

  1. Procedural DMLs : require a user to specify what data are needed and how to get those data.
  2. Declerative DMLs (also referred as Non-procedural DMLs) : require a user to specify what data are needed without specifying how to get those data.

    Declerative DMLs are usually easier to learn and use than are procedural DMLs. However, since a user does not have to specify how to get the data, the database system has to figure out an efficient means of accessing data.


DCL (Data Control Language) :

A Data Control Language is a syntax similar to a computer programming language used to control access to data stored in a database (Authorization). In particular, it is a component of Structured Query Language (SQL).


The operations for which privileges may be granted to or revoked from a user or role apply to both the Data definition language (DDL) and the Data manipulation language (DML), and may include CONNECT, SELECT, INSERT, UPDATE, DELETE, EXECUTE and USAGE.


In the Oracle database, executing a DCL command issues an implicit commit. Hence, you cannot roll back the command.



TCL (Transaction Control Language) :

Transaction Control Language commands are used to manage transactions in database. These are used to manage the changes made by DML-statements. It also allows statements to be grouped together into logical transactions.




'프로그래밍 > ---DBMS---' 카테고리의 다른 글

관계 데이터 연산  (0) 2018.09.29
정규화란?  (0) 2018.09.29

+ Recent posts