2.1 Structure of relational Database


table == Relation


Attribute : Column of talbe

Tuple : row in table


*Attribute types

-Domain : the set of allowed vlaues for each attribute

-Attribute values are required to be atomic, that is indivisible

-Null 값이 들어갈수도 있다


*NULL 값이란?

-값이 무엇인지 정의할 수 없는 경우 사용될 수 있다. : 알려지지 않은 값

-값이 무엇인지 알 수 없는 경우

-적용 불가능한 값

-보류된 값


2.2 Database Schema


데이터베이스는 여러 Relation으로 이루어져있다


        • Database Schema : Logical design of the database


        • Database instance : A snapshot of the data in the database at a given instant in time


        • Relation schema : Logical design of a table (Attribute와 연관된 Domains)


        • Relation instance : A snapshot of the data in a table at a given instant in time



2.3 Keys

K가 R에 속해있을때
K is a SuperKey of R if values for K are sufficient to identify a unique tuple of each possible relation r(R)

: 슈퍼키는 유일성을 만족하는 Attribute이다. 유일성은 키가 갖추어야 하는 기본 특성으로, 하나의 relation에서 키로 지정된 속성의 값은 tuple마다 달라야한다는 것이다. 즉 키 값이 같은 tuple은 존재하지 못한다. 예로는 고객 아이디 같은 것이 있는데 고객아이디가 들어간 모든 집합은 super key 가 된다


Candidate Key is minimal superkey for which no proper subset is a superkey
:후보키는 슈퍼키의 일부분으로 유일성과 최소성을 만족해야한다. 최소성은 키를 구성하고 있는 여러 속성 중에서 하나라도 없으면 tuple을 유일하게 구별할 수 없는, 꼭 필요한 것들로만 키를 구성한다는 것이다. 예를 들어 superkey중에 하나의 원소로만 되있으면 후보키이다.



One of the candidate keys is selected to be the Primary key

: 기본키는 tuple을 구별하는 최소 단위를 기본키라고 한다. 후보키의 부분에 속한다.



Foreign key constraint : value in one relation must appear in another
-Referencing relation
-Referenced relation
 : 다른 relation을 참조하거나 참조되는 Column




2.4 Schema Diagram

foreign key와 primary key같은 것들의 상관관계를 보여주는 shcema diagrams이다





2.5 Relational Query Lanuages

Procedural vs Non-procedural, or Declarative(???????)

Pure Languages:
-Relational algebra
-Tuple relational calulus
-Domain relational calculus

Relational operators
        1. Selection
        2. Project
        3. Union
        4. Difference
        5. intersection
        6. Join
          1. Cartesian product
          2. Natural Join

1.Selection
Chooses the tuples in a relation which satisfy certain conditions

ex) SELECT Product Name Where Unit Price > 4000



2.Projection

Extract data Vertically(as a column)

Choses some of the attributes of the relation

ex) PROJECT Product Name


3.Union

합집합이다 중복된 것은 제거한다


4.Difference

차집합니다. 




5.Intersection

교집합이다.



6.Cartesian Product

행렬 곱하기 이다 3줄 x 3줄 = 9줄 이렇게



7.Natural Join

Relation R과 S에 공통적으로 존재하는 속성들을 이용하여 공통 속성들의 값들이 서로 같은 Tuple들을 조인하는 것이다. 쉽게 말해 같은 부분을 기준으로 두 Relation을 하나로 합침




전체 요약

'일상 > DataBase' 카테고리의 다른 글

SQL 소개 (2)  (0) 2017.09.28
3.SQL 소개(1)  (0) 2017.09.28
SQL 공부 1  (0) 2017.09.27
1.데이터베이스(DataBase)란  (0) 2017.09.27

1.1 DataBase Management System(DBMS)


DBMS contains information about a particular enterprise

ex)  Banking : transactions
     Airlines : reservations, schedules
     Universities : registration, grades
Manufacturing : production, inventory, orders, supply chain etc..

1.2 Purpose of Database Systems

데이터 베이스를 사용하는 이유는 대부분 정보를 저장하기 위해서이다.
    1. Data redundancy and inconsistency
    2. Difficulty in accessing data
    3. Data isolation - multiple files and formats
    4. integrity problems
    5. Atomicity of updates
    6. Concurrent access by multiple users
    7. Security problems
1.3 View of Data

    • Physical level : describes how a record is stored.
    • Logical level : describes data stored in database and the relationships among the data
    • View level : application programs hide details of data types. can also hide information for security
 - Architecture for a databse system


    • Schema : the logical structure of the database

  Analogous to type information of a variable in a program


-Physical Schema : database desigan at the physical level

-Logical Schema : database design at the logical level


    • Instance : the actual content of the database at a particular point in time 

  Analogous to the value of a variable


    • Physical Data Independence : Ability to modify the physical shema without changing the logical schema

- 하지만 대부분 심각하게 영향을 주지는 않는다.


    • Data Models  
      1. Relation model
      2. Entity-relationship data model
      3. Object-based data models
      4. Semistructured data model (XML) ETC..

1.4 Database Language

    • Data Definition Language(DDL) : Specify the database schema
    • Data Mnipulation Language(DML) : Express database queries and updates
보통 두개로 나누어진다. 하지만 두개가 완전히 분리되있는 것은 아니고 SQL 언어의 한 부분이다.

DDL
-Specification notation for defining the database schema
-DDL compiler generates a set of table templates stored in a data dictionary

-Data Dictionary contains metadata

Database schema

Integrity constraints

§Primary key (ID uniquely identifies instructors)

§Referential integrity(references constrint in SQL )


DML

-Accessing and manipulating the data organized by the appropriate data model

-DML은 Query Language이다

-Two classes of languages

§Procedural - user specifies what data is reuired and how to get those data

§Declarative(nonprocedural) - user specifies what data is required without specifying how to get those                               data


1.5 Relation Model


2장에서 다시 언급하겠다


*SQL : widely used non-procedural language


보통 프로그램은 데이터베이스에 접근하기 위해 다음 것들 중하나를 이용한다

-Language extensions to allow embedded SQL

-Application program interface which allow SQL queries to be sent to a database


1.6 Database Design


Logical Design : Deciding on the database schema. Database design requires that we find a "good" collection                 of relation schemas


Physical Design : Deciding on the physical layout of the database



*The Entity-relationship Model

- Models an enterprise as a collection of entities and relationships

entity : a thing or object in the enterpries that is distinguishable from other objects

relationship : an association among several entities


*Object-relational Data Model

-Extend the relational data model by including object orientation and constructs to deal with added data   types


1.7 Storage Management


-a program module that provies the interface between the low-level data stored in the database and the   application programs and queries submitted to the system


1.8 Query Processing

    1. Parsing and translation
    2. Optimization
    3. Evaluation이 이상은 이해가 안됬습니다.

1.9 Transaction Management


Transaction : a collection of operations that perfoms a single logical function in database application


1.10 Database Architecture

전체구상도

세부구상도

'일상 > DataBase' 카테고리의 다른 글

SQL 소개 (2)  (0) 2017.09.28
3.SQL 소개(1)  (0) 2017.09.28
SQL 공부 1  (0) 2017.09.27
2. Relational Model이란  (0) 2017.09.27

+ Recent posts