TIL(23-01-25)

allnight5·2023년 1월 25일
0

TIL

목록 보기
41/55

DDL, DML, DCL

1.DDL : Data Define Language

스키마/도메인/테이블/뷰/인덱스를 정의/변경/제거할 때 사용하는 언어이다.
테이블을 생성하고, 테이블 내용을 변경하고, 테이블을 없애버리는 것.

2.DML : Data Manipulation Language

Query(질의)를 통해서 저장된 데이터를 실질적으로 관리하는 데 사용한다.
흔히 INSERT, DELETE, UPDATE 를 떠올리면 된다.

3.DCL : Data Control Language

보안/무결성/회복/병행 제어 등을 정의하는데 사용한다. 데이터 관리 목적.
흔히 COMMIT, ROLLBACK, GRANT, REVOKE 를 떠올리면 된다.

VO,DAO,DTO, Domain(=Entity)

VO(value Object)

DTO와 동일한 개념이나 차이점은 내부 속성 값을 변경할 수 없는, Read–Only 속성 객체이다.

DAO(Data Access Object)

repository package
실제로 DB에 접근하여 Data를 CRUD하는 객체.

DTO(Data Transfer Object)

dto package
계층 간 데이터 교환을 위한 Java Beans.
View와 통신하기 위한 클래스.

Domain(=Entity)

domain package
실제 DB의 테이블과 매칭시키는 클래스.
Entity와 DTO를 분리하는 이유
Entity는 DB Layer를 위한, DTO는 View Layer를 위한 것.

복습하기

인터페이스

인터페이스를 구현하면 아래와같다
우선 인터페이스를 생성한다.

interface Flyable{
  void fly(int x, int y, int z);
}

인터페이스 구현채를 만든다.

class Pigeon implements Flyable{
##변수 선언
    private int x,y,z;
 
    public void fly(int x, int y, int z) {
        printLocation();
        System.out.println("날아갑니다.");
        this.x = x;
        this.y = y;
        this.z = z;
        printLocation();
    }
    public void printLocation(){
        System.out.println("현재위치 (" +x +", " +y+", "+z+")");
    }
}
class Play implements Flyable{
##변수 선언
    private int x;
 
    public void fly(int x) {
        printLocation();
        System.out.println("현재위치");
        this.x = x; 
        printLocation();
    }
    public void printLocation(){
        System.out.println("현재위치 x");
    }
}

구현한 인터페이스를 선언하고 인터페이스 구현체를 가져온다.

public class TestApplication {
    public static void main(String[] args) { 
        Flyable flyable = new Pigeon(); 
        flyable.fly(1,3,5);
        Flyable able = new Play();
        able.fly(3);
    }
}

오버로딩, 오버라이딩

오버로딩은 이미 작성된 메서드를 다른메서드에서 불러와 사용할때 내용을 변경해서 사용할때 사용한다.

class Animal
    public int cry(int a, int b){
       return a+b;        
    }
class Dog extends Animal
	@Override
    public int cry(int a, int b){
       return a*b;        
    }

오버 라이딩의 경우 한 메서드 내에서 같은 이름이 있을때 들어가는 파라미터의 형태를 다르게 한다던가 말이다.

    long example (int a, int b){
        return a+b;
    }
    long example (int a, long  b){
        return a+b;
    }
    long example (String one, long two){
        return Integer.parseInt(one)+two;
    } 
    long example (long one){
    	return one;
    }
profile
공부기록하기

0개의 댓글