기술(Tech, IT)/데이터베이스(Database) 8

[DB] Transaction(트랜잭션) 정의 및 MySQL 명령어

Transaction에 정의는 위키피디아에 따르면 아래와 같다. :In computer science, transaction processing is information processing that is divided into individual, indivisible operations called transactions. Each transaction must succeed or fail as a complete unit; it can never be only partially complete. : 컴퓨터 과학에서 Transaction 처리는 더이상 분리되지 않는 연산 정보 처리를 말한다. 각 Transaction은 처리를 완전히 성공하거나 실패해야한다. 즉, 부분적은 처리는 허락되지 않는다. Da..

[DB] JOIN - OUTER JOIN

다음은 Explicit JOIN의 나머지 하나인 OUTER JOIN에 대해 알아보자. OUTER JOIN에 대한 설명은 아래와 같다. : Allows you to specify one of the tables as always contributing to the result. There are 2 types of OUTER JOINs - LEFT OUTER JOIN and RIGHT OUTER JOIN. OUTER JOINs are joins that return matched values and unmatched values from either or both sides. : 하나의 테이블을 반드시 결과에 나타나도록 허용할 수 있다. OUTER Join엔 2개의 종류가 있는데 LEFT OUTER JOI..

[DB] JOIN - INNER JOIN (2)

앞서 Implicit JOIN에 대해 살펴봤고, 이제 보편적으로 사용하는 Explicit JOIN에 대해 알아보겠다. Explicit JOIN엔 INNER JOIN과 OUTER JOIN이 있다. INNER JOIN에 대한 설명은 아래와 같다. : Produces a tuple in the result when there is a corresponding matching tuple in both the table : 두 테이블에 상응하는 튜플이 있다면 이를 하나의 튜플로 생성하는 것을 말한다. 예제를 살펴보자. SELECT id, name, school FROM student INNER JOIN student_major ON id = student_id; : id, name, school 속성을 stude..

[DB] JOIN - Implicit JOIN (1)

Join에 대한 이해부터 시작하자. Join이란 아래와 같다. :Typically, we want only combinations of the Cartesian product that satisfy certain conditions and so we would normally use a Join operation instead of the Cartesian product operation. The Join operation, which combines two relations to form a new relation, is one of the essential operations in the relational algebra. : 특정 조건을 만족하는 Cartesian product(곱집합)을 만들고자 ..

[DB] Super Key, Candidate Key, Primary Key, Alternate Key, Foreign Key

Relational keys : We need to be able to identify one or more attributes that uniquely identifies each tuple in a relation. : 우리는 relation(관계) 속에서 각 튜플(row)를 고유하게 인식 또는 분간해주는 하나 또는 여러개의 속성이 필요한데 이를 relational keys라고 한다. Relational key의 종류는 아래와 같다. 1. Super Key(슈퍼키) : An attribute, or set of attributes, that uniquely identifies a tuple within a relation. : 하나 또는 여러 속성의 집합으로 각 튜플을 고유하게 구분해준다. 즉, Su..

[DB] Functional Dependency(함수 종속성) - (1)

Thomas Connolly와 Carolyn Begg의 저서인 Database Systems, A Practical Approach to Design, Implementation and Management Sixth Edition에 따르면 Funtional Dependency에 대한 정의는 아래와 같다. : Describes the relationship between attributes in a relation. For example, if A and B are attributes of realation R, B is functionally dependent on A, if each value of A is associated with exactly one value of B. (A and B may ..

[DB] MySQL CHAR, VARCHAR 차이

MySQL 문법의 자료형 중 문자열을 나타내는 자료형으로 CHAR와 VARCHAR가 있다. 둘을 아래와 같은 차이를 갖고있다. 1. CHAR - 고정형: CHAR(32)로 선언될 경우 몇 바이트의 문자열이 주어지던 32 bytes가 할당된다. - 메모리 고려 시엔 낭비가 될 수도 있지만, 메모리가 고정된 만큼 검색 및 데이터 접근과 같은 시간 측면에선 VARCHAR 대비 우수하다. 2. VARCHAR - 가변형: VARCHAR(32)로 선언돼도 주어진 문자열 길이만큼 메모리가 할당된다. 예를 들어, "Daniel"로 6 bytes가 입력되면 메모리는 6 bytes만 할당된다. - CHAR 대비 메모리 효율적이지만, 시간 복잡도 측면에선 떨어진다. 참고 - https://byul91oh.tistory.co..

[DB] MySQL Workbench

:MySQL Workbench is a unified visual tool for database architects, developers, and DBAs*. MySQL Workbench provides data modeling, SQL development, and comprehensive administration tools for server configuration, user administration, backup, and much more. MySQL Workbench is available on Windows, Linux and Mac OS X. : MySQL Workbench는 데이터베이스 설계자나 개발자 혹은 관련 사업을 하는 사람들을 위한 통합 시각 툴이다. MySQL Workbenc..