|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, January 13, 2011 7:55 PM
Points: 124,
Visits: 12
|
|
| What is the recommended datatype for Gender?
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Friday, June 14, 2013 2:36 PM
Points: 414,
Visits: 2,750
|
|
could think of a few rather un pc answers but don't think that will help your database issue
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Yesterday @ 1:51 PM
Points: 1,469,
Visits: 943
|
|
In reality its a boleean so bit is fine just have to decide 0 = Male, 1 = Female or 1 = Male, 0 = Female How bout Char(1) M (Male) F (Female) U (Unknown) B (Both)
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, January 13, 2011 7:55 PM
Points: 124,
Visits: 12
|
|
| Char(1) sound better. I think Boolean might give problems for NULL data.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, January 13, 2011 7:55 PM
Points: 124,
Visits: 12
|
|
| Char(1) sound better. I think Boolean might give problems for NULL data.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: 2 days ago @ 5:46 AM
Points: 2,636,
Visits: 2,788
|
|
I would go for char(1). Many poorer countries do not perform gender assignment surgery for those babies whose bits are not obvious.
Author: SQL Server FineBuild 1-click install and best practice configuration of SQL Server 2012, 2008 R2, 2008 and 2005. 4 June 2013: now over 24,000 downloads. Disclaimer: All information provided is a personal opinion that may not match reality. Concept: "Pizza Apartheid" - the discrimination that separates those who earn enough in one day to buy a pizza if they want one, from those who can not.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 4:59 PM
Points: 11,792,
Visits: 28,078
|
|
i typically use a char(1) with a check constraint to allow only two values: ie ALTER TABLE BLAH ADD GENDER CHAR(1) NULL CHECK (GENDER='M' OR GENDER='F')
Lowell
--There is no spoon, and there's no default ORDER BY in sql server either. Actually, Common Sense is so rare, it should be considered a Superpower. --my son
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Monday, June 03, 2013 10:38 AM
Points: 199,
Visits: 55
|
|
varchar(1) Null is unknown. That is the purpose of null. >How bout >Char(1) >M (Male) >F (Female) >U (Unknown) >B (Both)
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, January 13, 2011 7:55 PM
Points: 124,
Visits: 12
|
|
| I see that char or varchar is recommended. Any reason to choose one over the other? What is the selection process to select char, varchar, nvarchar?
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Monday, June 03, 2013 10:38 AM
Points: 199,
Visits: 55
|
|
Because of my indoctrination by Oracle DBAs, I use varchar and never use char. The reason for nvarchar would be for international character purposes. I have never seen a compelling reason to use char.
|
|
|
|