gender (성별)을 사용되는 데이터 타입은 어떤것이 좋을까요?
결론 부터 이야기 하자면,Char(1)을 추천하네요.
너무 단순한 질문일지 몰라도, DB의 데이터의 양을 줄이는 것에 대해서 신경을 쓰는 것은 유익한 노력입니다.
I'd call the column "gender".
Data Type Bytes Taken Number/Range of Values
------------------------------------------------
TinyINT 1 255 (zero to 255)
INT 4 - 2,147,483,648 to 2,147,483,647
BIT 1 (2 if 9+ columns) 2 (0 and 1)
CHAR(1) 1 26 if case insensitive, 52 otherwise
If there's a need to support more than two genders, the BIT data type can be ruled out for the sake it can't support them. While INT supports more than two options, it takes 4 bytes -- performance will be better with a smaller/more narrow data type.
CHAR(1)
has the edge over TinyINT - both take the same number of bytes, but CHAR provides a more narrow number of values. Using CHAR(1)
would make using "m", "f",etc natural keys, vs the use of numeric data which are referred to as surrogate/artificial keys. CHAR(1)
is also supported on any database, should there be a need to port.
Conclusion
I would use Option 2: CHAR(1).
Addendum
An index on the gender column likely would not help because there's no value in an index on a low cardinality column. Meaning, there's not enough variety in the values for the index to provide any value.
출처: http://stackoverflow.com/questions/4175878/storing-sex-gender-in-database
'DB관련 > SQL Server' 카테고리의 다른 글
MSSQL 특정 테이블 백업하기 (0) | 2017.01.26 |
---|---|
MSSQL 소숫점 자리수 맞추기 (0) | 2016.02.20 |
[error 메모] String or binary data would be truncated. (0) | 2016.02.17 |
MS SQL SERVER 버전별 + Version List (0) | 2015.12.30 |
[중요] Left join and Left outer join in SQL Server (0) | 2015.11.12 |
Update sql bit field in database (0) | 2015.11.12 |
localhost로 사용하기 (0) | 2015.08.21 |
Convert a date 를 yyyymmdd format 형식으로 변경 (0) | 2015.07.31 |
(로그인하지 않으셔도 가능)