웹찢남

Database - 1일차 본문

Database

Database - 1일차

harry595 2020. 10. 1. 19:37

Table

  • set of rows
  • Each row - a different entity
  • Each column - a particular fact about each entity

Relation - relation name(table),attributes,Tuples(row)

Structured Query Language (SQL)

  • Language for manipulating tables
  • Declarative - Statement specifies what needs to be obtained, not how it is to be achieved

Key of Relation:

  • row 마다 유니크한 정보가 있는데 key라고 한다.

Formal Definitions - Schema

  • Schema of a Relation
  • ex) Customer(Cust-id,Cust-name,address,phone) 이런식으로 나타냄

Formal Definitions - Tuple

  • Tuple은 위의 스키마에 예를 들어 <643252,"지운","산본동",010~> 이런걸 뜻함

Formal Definitions - Domain

  • Domain은 논리적인 정의를 뜻함
  • ex) 미국 폰번은 10개의 숫자로 이루어졌다.
  • 날짜는 yyyy-mm-dd여야함

Formal Definitions - State

  • relation state는 tuples의 모든 가능한 부분집합이다

Integrity Constraints

 

Constraints Checking

  • Automatically checked by DBMS
  • protects database from errors
  • Enforces enterprise rules

Constraints 는 어떤게 db에서 허용가능한지 불가능한지 판단한다.

  • Interent or Implicit Constraints: based on the data model itself
  • Schema-based or Explicit Constraints
  • Application based or semantic constraints

Kinds of Integrity Constraints

  • static constraint - restricts legal states of DB
  • Syntactic(structural)
  • ⇒ ex) column의 모든 값들은 unique 해야함
  • Semantic(involving meaning of attributes)
  • ⇒ ex) cannot register for more than 18 credits
  • Dynamic constraint - limitation on sequence of DB states
  • ⇒ ex) cannot raise salary by more than 5%

Key constraints

  • superkey ⇒ K가 Relation R의 tuple들을 유일하게 구별할 수 있는 집합이면 K는 SuperKey 집합니다. 하나의 attribute가 해당 row를 유일하게 구별한다면 SuperKey라는 것
  • Candidate Key → 위에서 superkey의 K중 가장 minimal 한것 예를들어 superkey 중에는 {[학번],[아이디],[학번,이름]} 이런식을때 학번 , id가 candidate key이다.
  • Primary key → candidate key 중 하나 (Null 이 될 수 없음)
  • Foreign Key → R1이 R2와 같은 값을 가지고 대응할때 R1을 FK라 함

'Database' 카테고리의 다른 글

Database - 5일차  (0) 2021.02.02
동읍면 DB 만들기  (0) 2020.11.11
Database - 4일차  (0) 2020.10.26
Database - 3일차  (0) 2020.10.07
Database - 2일차  (0) 2020.10.03
Comments