Programming-[Backend]/SQL

[링크][작성중] SQL Server Naming Convention

컴퓨터 탐험가 찰리 2021. 9. 6. 16:13
728x90
반응형

참조1의 내용을 바탕으로함

 

1. 테이블 이름

약어를 tbl로 쓰고, 이름은 복수형으로 쓴다.

tblEmployees, tblOrders, tblProducts

 

2. 제약 조건

PK : Primary Key, FK : Foreign Key, UQ : Unique Key, DF : Default, CHK : Check

 

PK_Employees, PK_Orders, PK_Products

FK_Orders_Employees, FK_Items_Products (Target 테이블_Source 테이블 순)

UQ_Employees_EmailID, UQ_Items_Code (테이블 이름_컬럼 이름)

DF_Employees_IsActive, DF_Employees_CreateDate(테이블 이름_컬럼 이름)

CHK_Employees_Salary, CHK_Employees_DOB(테이블 이름_컬럼 이름)   ※ DOB는 Date of Birth라고 함 ㅎ

 

Check 제약 조건을 이용하면 테이블에 입력될 수 있는 값에 Validation을 걸 수 있다.

(

참조2의 내용 :

CHECK 제약 조건을 만들어 salary 열의 값 범위를 제한할 수 있습니다. 이렇게 하면 정상 월급 범위를 벗어나는 월급은 입력되지 않습니다. 논리 식은 다음과 같습니다. salary >= 15000 AND salary <= 100000

)

 

3. 


 

참조

 

참조1.

https://www.dotnettricks.com/learn/sqlserver/sql-server-naming-conventions-and-standards

 

참조2.

https://docs.microsoft.com/ko-kr/sql/relational-databases/tables/unique-constraints-and-check-constraints?view=sql-server-ver15

 

참조3.

https://phobyjun.github.io/2019/09/21/%EC%82%AC%EC%9A%A9%EC%9E%90-%EC%A0%95%EC%9D%98-%ED%95%A8%EC%88%98(User-Defined-Function)-in-sql-server.html

728x90
반응형