2011-11-26 5 views
0

사용자의 계정 설정은 원하는 세부 정보에 따라 상당히 길 수 있습니다 (예 : 뉴스 레터 수신 TINYINT(1), 검색 허용 TINYINT(1) 등). 이 작업을 수행하는 가장 좋은 방법은 지금 당장이 모든 설정이 이미 약 30 개의 열이 있고 곧 커질 수있는 내 사용자 테이블에 저장되어 있기 때문에 무엇인지 알고 싶습니다.MySQL : 사용자의 계정 설정 테이블 디자인

답변

0

당신은 set 데이터 유형을 사용하여 고려할 수 있습니다 : - 쿼리를 수행 할 때 http://dev.mysql.com/doc/refman/5.0/en/set.html

profile set ('newsletter', 'searchable', ....) 

, 그것은 것입니다 : - 양자 택일

select ... from user 
where find_in_set('searchable', profile)>0 and ... 

, 당신은 각 프로파일을 정상화하기 위해 프로파일 테이블을 만들 수 있습니다 하나의 기록이 되십시오.

user (id, ...); 
user_profile (user_id, profile_id, profile_value); 
profile (id, name); 

검색 : -

select ... from user 
inner join user_profile on user.id=user_profile.user_id 
inner join profile on profile.id=user_profile.profile_id 
where profile.name='searchable' and user_profile.profile_value=1 ... 
+0

그런 다음 다 대다 관계를 사용한다는 의미입니다. 좋은 소리. – enchance

관련 문제