agrupando linhas com COUNT

31/05/2016

0

Bom dia, preciso de um auxílio

tenho a seguinte situação:

Tabelas utilizadas: (matriculas / classificacao / performances)

o resultado que preciso é o seguinte:

classificacao | licenca | Qtd Total
curso1 | 20 | 78
curso2 | 43 | 56
curso3 | 50 | 50
curso4 | 187 | 236

o select que estou utilizando é

SELECT
class.classification_name,
COUNT(DISTINCT matricula.user_id)

from users_in_groups matricula

LEFT JOIN users usr ON (matricula.user_id = usr.user_id AND usr.user_name IS NOT NULL)
JOIN groups cursos ON (matricula.group_id = cursos.group_id)
JOIN classifications class ON (class.classification_id = cursos.classification_id)

este select está retornando apenas 1 linha e não todas as "classificações" com a contagem em cada linha
Luciano

Luciano

Responder

Posts

31/05/2016

Douglas Noronha

Coloque a estrutura das tabelas.
Responder

31/05/2016

Luciano

Boa tarde,
o select original é este:

SELECT COUNT(DISTINCT a.user_id) active_users
FROM users_in_groups a
JOIN users u ON (a.user_id = u.user_id AND u.user_name IS NOT NULL)
JOIN groups b ON (a.group_id = b.group_id)
LEFT JOIN course_performances c ON (c.user_id = a.user_id AND c.group_id = b.group_id)
WHERE b.group_type = 'Group' AND c.c_performance_score IS NULL

neste select retorna apenas a contagem total (usuários que estão na tabela users_in_groups e que performance IS NULL)

porém necessito que este total seja divido por classifications.classification_name

segue a estrutura das tabelas

tabela users

"Field" "Type" "Null" "Key" "Default" "Extra"
"user_id" "mediumint(8) unsigned" "NO" "PRI" \N "auto_increment"
"user_name" "varchar(50)" "YES" "UNI" \N ""
"user_first_name" "varchar(60)" "YES" "" \N ""
"user_last_name" "varchar(60)" "YES" "" "" ""
"user_password" "varchar(32)" "NO" "" "" ""
"user_email" "varchar(100)" "NO" "" "" ""
"user_hide_email" "tinyint(1) unsigned" "NO" "" "1" ""
"user_no_notifications" "tinyint(1) unsigned" "NO" "" "0" ""
"user_location" "varchar(50)" "YES" "" \N ""
"user_birthdate" "date" "YES" "" \N ""
"user_identity_num" "varchar(40)" "YES" "" \N ""
"user_theme_id" "int(11)" "YES" "" \N ""
"user_avatar" "varchar(100)" "YES" "" \N ""
"user_joined" "int(10) unsigned" "NO" "" "0" ""
"user_lastvisit" "int(10) unsigned" "NO" "" "0" ""
"user_ip" "varchar(40)" "NO" "" "0.0.0.0" ""
"user_type" "enum('Admin','User','Power')" "YES" "" "User" ""
"user_enabled" "int(10) unsigned" "NO" "" "1" ""
"user_expiration" "int(10) unsigned" "NO" "" "0" ""
"user_language" "varchar(32)" "YES" "" \N ""
"user_current_session_id" "varchar(32)" "YES" "" \N ""
"user_allowed_multiple_sessions" "tinyint(1)" "NO" "" "0" ""
"user_company" "varchar(128)" "YES" "" \N ""
"user_job_title" "varchar(128)" "YES" "" \N ""
"user_business_phone" "varchar(64)" "YES" "" \N ""
"user_home_phone" "varchar(64)" "YES" "" \N ""
"user_mobile_phone" "varchar(64)" "YES" "" \N ""
"user_fax_number" "varchar(64)" "YES" "" \N ""
"user_address" "varchar(64)" "YES" "" \N ""
"user_city" "varchar(64)" "YES" "" \N ""
"user_state" "varchar(64)" "YES" "" \N ""
"user_postal_code" "varchar(64)" "YES" "" \N ""
"user_country" "varchar(64)" "YES" "" \N ""
"user_gender" "enum('Male','Female')" "YES" "" \N ""
"user_temp_password" "tinyint(1)" "YES" "" \N ""
"domain_id" "smallint(5) unsigned" "YES" "MUL" "1" ""
"old_user_name" "varchar(50)" "YES" "" \N ""
"user_pretend" "int(10) unsigned" "YES" "" \N ""
"external_id" "varchar(30)" "YES" "MUL" \N ""
"user_pw_recovery_key" "varchar(32)" "YES" "" \N ""
"user_pw_set_time" "int(11)" "YES" "" \N ""
"user_extra_time" "tinyint(1) unsigned" "YES" "" \N ""
"classification_id" "mediumint(8) unsigned" "YES" "" \N ""
"employment_date" "date" "YES" "" \N ""
"chat_off" "int(10) unsigned" "YES" "" \N ""
"cache_theme_id" "int(11)" "YES" "" \N ""
"user_nt" "varchar(255)" "YES" "" \N ""
"last_social_notication_time" "int(10) unsigned" "YES" "" \N ""
"user_timezone" "varchar(40)" "YES" "" \N ""
"user_date_format" "enum('default','america')" "YES" "" \N ""
"notification_settings" "varchar(256)" "YES" "" \N ""
"user_deleted_time" "int(11)" "YES" "" \N ""
"last_mail_notification" "int(10) unsigned" "YES" "" "0" ""
"mail_notification_span" "int(10) unsigned" "YES" "" "600" ""
"status_id" "int(10) unsigned" "YES" "MUL" \N ""
"user_report_fields" "text" "YES" "" \N ""
"email_validation_key" "varchar(50)" "YES" "" \N ""
"last_gui_notification" "int(10) unsigned" "YES" "" \N ""
"slave_to_multiuser" "mediumint(8) unsigned" "YES" "MUL" \N ""
"active_multiuser" "mediumint(8) unsigned" "YES" "MUL" \N ""
"facebook_id" "decimal(30,0)" "YES" "UNI" \N ""
"google_id" "decimal(30,0)" "YES" "UNI" \N ""

tabela groups

"Field" "Type" "Null" "Key" "Default" "Extra"
"group_id" "int(10) unsigned" "NO" "PRI" \N "auto_increment"
"group_name" "varchar(200)" "NO" "" "" ""
"group_description" "text" "YES" "" \N ""
"group_image" "varchar(255)" "YES" "" \N ""
"group_access" "enum('private','public','register','manager_register')" "NO" "" "private" ""
"reminder_due_date" "tinyint(2) unsigned" "NO" "" "0" ""
"reminder_late" "enum('No','Yes')" "NO" "" "No" ""
"domain_id" "smallint(5) unsigned" "YES" "MUL" "1" ""
"discussions_off" "tinyint(1) unsigned" "NO" "" "0" ""
"group_options" "varchar(2048)" "YES" "" \N ""
"external_id" "varchar(255)" "YES" "" \N ""
"group_type" "enum('Group','Role','Ou','Stage','Course_template','Course_external','Qualification','Subset','Workplan','Budget','ResourceBundle','Job','Recruitment')" "NO" "" "Group" ""
"deleted" "tinyint(3) unsigned" "YES" "" \N ""
"group_invisible" "tinyint(1) unsigned" "NO" "" "0" ""
"is_course" "tinyint(1) unsigned" "YES" "" \N ""
"group_open_date" "int(10) unsigned" "YES" "" \N ""
"group_close_date" "int(10) unsigned" "YES" "" \N ""
"group_theme_id" "int(11)" "YES" "MUL" \N ""
"origin_group" "int(10) unsigned" "YES" "MUL" \N ""
"group_location" "varchar(100)" "YES" "" \N ""
"estimated_budget" "int(10) unsigned" "YES" "" \N ""
"actual_budget" "int(10) unsigned" "YES" "" \N ""
"classification_id" "mediumint(8) unsigned" "YES" "" \N ""
"expected_participants" "smallint(5) unsigned" "YES" "" \N ""
"auto_complete_course" "tinyint(1) unsigned" "YES" "" \N ""
"course_certificate" "smallint(5) unsigned" "YES" "" \N ""
"registration_type" "enum('reg_to_instances','reg_to_template')" "YES" "" \N ""
"group_public" "tinyint(1)" "YES" "" \N ""
"sequence_id" "int(10) unsigned" "YES" "" \N ""
"syllabus_file" "varchar(100)" "YES" "" \N ""
"syllabus_text" "text" "YES" "" \N ""
"min_users" "smallint(5) unsigned" "YES" "" \N ""
"max_users" "smallint(5) unsigned" "YES" "" \N ""
"registration_start_date" "int(10) unsigned" "YES" "" \N ""
"registration_end_date" "int(10) unsigned" "YES" "" \N ""
"teacher_score_weight" "int(5) unsigned" "YES" "" "0" ""
"required_seniority" "varchar(45)" "YES" "" \N ""
"required_period" "varchar(45)" "YES" "" \N ""
"required_meetings_attendance" "smallint(5) unsigned" "YES" "" "0" ""
"passing_grade" "smallint(5) unsigned" "YES" "" \N ""
"welcome_text" "text" "YES" "" \N ""
"limit_reminder" "smallint(2) unsigned" "YES" "" \N ""
"autoenrollment_rules" "text" "YES" "" \N ""
"sequence_start_date" "int(10) unsigned" "YES" "" \N ""
"registration_extra_info" "text" "YES" "" \N ""
"ical_uid" "varchar(50)" "YES" "" \N ""
"ical_sequence" "smallint(5) unsigned" "YES" "" \N ""
"no_attendance_reminder" "tinyint(3) unsigned" "YES" "" \N ""
"waiting_list_active" "tinyint(3) unsigned" "YES" "" \N ""
"cancel_grade_at_close" "tinyint(1) unsigned" "YES" "" \N ""
"archive" "tinyint(1) unsigned" "YES" "" \N ""
"inherit_dates_from_meetings" "tinyint(1) unsigned" "YES" "" \N ""
"view_pre_days" "int(10) unsigned" "YES" "" "0" ""
"view_post_days" "int(10) unsigned" "YES" "" "0" ""
"required_assignments_completion" "smallint(5) unsigned" "YES" "" "0" ""
"template_guard" "tinyint(1) unsigned" "YES" "" \N ""
"unpublished_grades" "tinyint(3) unsigned" "YES" "" \N ""
"complete_sub_qualifications" "tinyint(1) unsigned" "YES" "" \N ""
"show_to_anonymous" "tinyint(1) unsigned" "YES" "" \N ""
"member_expire" "smallint(5) unsigned" "YES" "" \N ""
"welcome_message_inherited" "tinyint(1) unsigned" "YES" "" \N ""
"template_parent" "int(10) unsigned" "YES" "" \N ""
"owner_options" "text" "YES" "" \N ""
"reg_availability_conditions" "text" "YES" "" \N ""
"auto_send_schedule" "tinyint(1) unsigned" "YES" "" \N ""
"optional_completion" "tinyint(1) unsigned" "YES" "" \N ""
"repeat_type" "enum('none','daily','weekly','monthly','yearly')" "YES" "" \N ""
"repeat_span" "smallint(2) unsigned" "YES" "" \N ""
"repeat_mode" "enum('first_success','from_last','each_success')" "NO" "" "first_success" ""
"repeat_end_date" "int(10) unsigned" "YES" "" \N ""
"status" "enum('draft','approval')" "YES" "" \N ""
"default_assignee" "mediumint(8) unsigned" "YES" "MUL" \N ""


tabela classifications
"Field" "Type" "Null" "Key" "Default" "Extra"
"classification_id" "mediumint(8) unsigned" "NO" "PRI" \N "auto_increment"
"classification_name" "varchar(100)" "NO" "MUL" \N ""
"classification_type" "enum('always','optional')" "NO" "MUL" \N ""
"domain_id" "smallint(5) unsigned" "NO" "MUL" "1" ""
"registration_limit" "smallint(5) unsigned" "YES" "" \N ""


tabela users_in_groups

"Field" "Type" "Null" "Key" "Default" "Extra"
"user_id" "mediumint(8) unsigned" "NO" "PRI" "0" ""
"group_id" "int(10) unsigned" "NO" "PRI" "0" ""
"addition_time" "int(10)" "YES" "" \N ""
"automatic_enrollment" "tinyint(1)" "YES" "" \N ""
"expire_time" "int(10) unsigned" "YES" "" \N ""
"amount" "decimal(4,2)" "YES" "" \N ""


tabela course_performances

"Field" "Type" "Null" "Key" "Default" "Extra"
"c_performance_id" "int(10) unsigned" "NO" "PRI" \N "auto_increment"
"group_id" "int(10) unsigned" "NO" "MUL" \N ""
"user_id" "mediumint(8) unsigned" "NO" "MUL" \N ""
"c_performance_date" "int(10) unsigned" "YES" "" \N ""
"c_performance_score" "tinyint(5)" "YES" "" \N ""
"teacher_score" "tinyint(5) unsigned" "YES" "" "0" ""
"c_completed" "tinyint(1) unsigned" "YES" "" \N ""
"teacher_note" "text" "YES" "" \N ""
Responder

31/05/2016

Luciano

CREATE TABLE `classifications` (
`classification_id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
`classification_name` VARCHAR(100) NOT NULL,
`classification_type` ENUM('always','optional') NOT NULL,
`domain_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '1',
`registration_limit` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
PRIMARY KEY (`classification_id`),
UNIQUE INDEX `classification_unique` (`classification_name`, `domain_id`),
INDEX `Index_2` (`classification_type`),
INDEX `ifk_c_did_idx` (`domain_id`),
CONSTRAINT `ifk_c_did` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`domain_id`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=15
;


CREATE TABLE `course_performances` (
`c_performance_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`group_id` INT(10) UNSIGNED NOT NULL,
`user_id` MEDIUMINT(8) UNSIGNED NOT NULL,
`c_performance_date` INT(10) UNSIGNED NULL DEFAULT NULL,
`c_performance_score` TINYINT(5) NULL DEFAULT NULL,
`teacher_score` TINYINT(5) UNSIGNED NULL DEFAULT '0',
`c_completed` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`teacher_note` TEXT NULL,
PRIMARY KEY (`c_performance_id`),
UNIQUE INDEX `unique_group_user` (`user_id`, `group_id`),
INDEX `ifk_cp_uid_idx` (`user_id`),
INDEX `ifk_cp_gid_idx` (`group_id`),
CONSTRAINT `ifk_cp_gid` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`) ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT `ifk_cp_uid` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=50
;


CREATE TABLE `groups` (
`group_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`group_name` VARCHAR(200) NOT NULL DEFAULT '',
`group_description` TEXT NULL,
`group_image` VARCHAR(255) NULL DEFAULT NULL,
`group_access` ENUM('private','public','register','manager_register') NOT NULL DEFAULT 'private',
`reminder_due_date` TINYINT(2) UNSIGNED NOT NULL DEFAULT '0',
`reminder_late` ENUM('No','Yes') NOT NULL DEFAULT 'No',
`domain_id` SMALLINT(5) UNSIGNED NULL DEFAULT '1',
`discussions_off` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
`group_options` VARCHAR(2048) NULL DEFAULT NULL,
`external_id` VARCHAR(255) NULL DEFAULT NULL,
`group_type` ENUM('Group','Role','Ou','Stage','Course_template','Course_external','Qualification','Subset','Workplan','Budget','ResourceBundle','Job','Recruitment') NOT NULL DEFAULT 'Group',
`deleted` TINYINT(3) UNSIGNED NULL DEFAULT NULL,
`group_invisible` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
`is_course` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`group_open_date` INT(10) UNSIGNED NULL DEFAULT NULL,
`group_close_date` INT(10) UNSIGNED NULL DEFAULT NULL,
`group_theme_id` INT(11) NULL DEFAULT NULL,
`origin_group` INT(10) UNSIGNED NULL DEFAULT NULL,
`group_location` VARCHAR(100) NULL DEFAULT NULL,
`estimated_budget` INT(10) UNSIGNED NULL DEFAULT NULL,
`actual_budget` INT(10) UNSIGNED NULL DEFAULT NULL,
`classification_id` MEDIUMINT(8) UNSIGNED NULL DEFAULT NULL,
`expected_participants` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
`auto_complete_course` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`course_certificate` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
`registration_type` ENUM('reg_to_instances','reg_to_template') NULL DEFAULT NULL,
`group_public` TINYINT(1) NULL DEFAULT NULL,
`sequence_id` INT(10) UNSIGNED NULL DEFAULT NULL,
`syllabus_file` VARCHAR(100) NULL DEFAULT NULL,
`syllabus_text` TEXT NULL,
`min_users` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
`max_users` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
`registration_start_date` INT(10) UNSIGNED NULL DEFAULT NULL,
`registration_end_date` INT(10) UNSIGNED NULL DEFAULT NULL,
`teacher_score_weight` INT(5) UNSIGNED NULL DEFAULT '0',
`required_seniority` VARCHAR(45) NULL DEFAULT NULL,
`required_period` VARCHAR(45) NULL DEFAULT NULL,
`required_meetings_attendance` SMALLINT(5) UNSIGNED NULL DEFAULT '0',
`passing_grade` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
`welcome_text` TEXT NULL,
`limit_reminder` SMALLINT(2) UNSIGNED NULL DEFAULT NULL,
`autoenrollment_rules` TEXT NULL,
`sequence_start_date` INT(10) UNSIGNED NULL DEFAULT NULL,
`registration_extra_info` TEXT NULL,
`ical_uid` VARCHAR(50) NULL DEFAULT NULL,
`ical_sequence` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
`no_attendance_reminder` TINYINT(3) UNSIGNED NULL DEFAULT NULL,
`waiting_list_active` TINYINT(3) UNSIGNED NULL DEFAULT NULL,
`cancel_grade_at_close` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`archive` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`inherit_dates_from_meetings` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`view_pre_days` INT(10) UNSIGNED NULL DEFAULT '0',
`view_post_days` INT(10) UNSIGNED NULL DEFAULT '0',
`required_assignments_completion` SMALLINT(5) UNSIGNED NULL DEFAULT '0',
`template_guard` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`unpublished_grades` TINYINT(3) UNSIGNED NULL DEFAULT NULL,
`complete_sub_qualifications` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`show_to_anonymous` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`member_expire` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
`welcome_message_inherited` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`template_parent` INT(10) UNSIGNED NULL DEFAULT NULL,
`owner_options` TEXT NULL,
`reg_availability_conditions` TEXT NULL,
`auto_send_schedule` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`optional_completion` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`repeat_type` ENUM('none','daily','weekly','monthly','yearly') NULL DEFAULT NULL,
`repeat_span` SMALLINT(2) UNSIGNED NULL DEFAULT NULL,
`repeat_mode` ENUM('first_success','from_last','each_success') NOT NULL DEFAULT 'first_success',
`repeat_end_date` INT(10) UNSIGNED NULL DEFAULT NULL,
`status` ENUM('draft','approval') NULL DEFAULT NULL,
`default_assignee` MEDIUMINT(8) UNSIGNED NULL DEFAULT NULL,
PRIMARY KEY (`group_id`),
UNIQUE INDEX `index_groups_external_id` (`domain_id`, `external_id`),
INDEX `fk_group_theme_id` (`group_theme_id`),
INDEX `i_gog` (`origin_group`),
INDEX `ifk_g_did_idx` (`domain_id`),
INDEX `ifk_g_da_idx` (`default_assignee`),
CONSTRAINT `fk_g_og` FOREIGN KEY (`origin_group`) REFERENCES `groups` (`group_id`) ON UPDATE SET NULL ON DELETE SET NULL,
CONSTRAINT `fk_group_theme_id` FOREIGN KEY (`group_theme_id`) REFERENCES `themes` (`theme_id`) ON UPDATE CASCADE ON DELETE SET NULL,
CONSTRAINT `ifk_g_da` FOREIGN KEY (`default_assignee`) REFERENCES `users` (`user_id`) ON UPDATE SET NULL ON DELETE CASCADE,
CONSTRAINT `ifk_g_did` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`domain_id`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=249
;


CREATE TABLE `users` (
`user_id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_name` VARCHAR(50) NULL DEFAULT NULL,
`user_first_name` VARCHAR(60) NULL DEFAULT NULL,
`user_last_name` VARCHAR(60) NULL DEFAULT '',
`user_password` VARCHAR(32) NOT NULL DEFAULT '',
`user_email` VARCHAR(100) NOT NULL DEFAULT '',
`user_hide_email` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',
`user_no_notifications` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
`user_location` VARCHAR(50) NULL DEFAULT NULL,
`user_birthdate` DATE NULL DEFAULT NULL,
`user_identity_num` VARCHAR(40) NULL DEFAULT NULL,
`user_theme_id` INT(11) NULL DEFAULT NULL,
`user_avatar` VARCHAR(100) NULL DEFAULT NULL,
`user_joined` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`user_lastvisit` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`user_ip` VARCHAR(40) NOT NULL DEFAULT '0.0.0.0',
`user_type` ENUM('Admin','User','Power') NULL DEFAULT 'User',
`user_enabled` INT(10) UNSIGNED NOT NULL DEFAULT '1',
`user_expiration` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`user_language` VARCHAR(32) NULL DEFAULT NULL,
`user_current_session_id` VARCHAR(32) NULL DEFAULT NULL,
`user_allowed_multiple_sessions` TINYINT(1) NOT NULL DEFAULT '0',
`user_company` VARCHAR(128) NULL DEFAULT NULL,
`user_job_title` VARCHAR(128) NULL DEFAULT NULL,
`user_business_phone` VARCHAR(64) NULL DEFAULT NULL,
`user_home_phone` VARCHAR(64) NULL DEFAULT NULL,
`user_mobile_phone` VARCHAR(64) NULL DEFAULT NULL,
`user_fax_number` VARCHAR(64) NULL DEFAULT NULL,
`user_address` VARCHAR(64) NULL DEFAULT NULL,
`user_city` VARCHAR(64) NULL DEFAULT NULL,
`user_state` VARCHAR(64) NULL DEFAULT NULL,
`user_postal_code` VARCHAR(64) NULL DEFAULT NULL,
`user_country` VARCHAR(64) NULL DEFAULT NULL,
`user_gender` ENUM('Male','Female') NULL DEFAULT NULL,
`user_temp_password` TINYINT(1) NULL DEFAULT NULL,
`domain_id` SMALLINT(5) UNSIGNED NULL DEFAULT '1',
`old_user_name` VARCHAR(50) NULL DEFAULT NULL,
`user_pretend` INT(10) UNSIGNED NULL DEFAULT NULL,
`external_id` VARCHAR(30) NULL DEFAULT NULL,
`user_pw_recovery_key` VARCHAR(32) NULL DEFAULT NULL,
`user_pw_set_time` INT(11) NULL DEFAULT NULL,
`user_extra_time` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`classification_id` MEDIUMINT(8) UNSIGNED NULL DEFAULT NULL,
`employment_date` DATE NULL DEFAULT NULL,
`chat_off` INT(10) UNSIGNED NULL DEFAULT NULL,
`cache_theme_id` INT(11) NULL DEFAULT NULL,
`user_nt` VARCHAR(255) NULL DEFAULT NULL,
`last_social_notication_time` INT(10) UNSIGNED NULL DEFAULT NULL,
`user_timezone` VARCHAR(40) NULL DEFAULT NULL,
`user_date_format` ENUM('default','america') NULL DEFAULT NULL,
`notification_settings` VARCHAR(256) NULL DEFAULT NULL,
`user_deleted_time` INT(11) NULL DEFAULT NULL,
`last_mail_notification` INT(10) UNSIGNED NULL DEFAULT '0',
`mail_notification_span` INT(10) UNSIGNED NULL DEFAULT '600',
`status_id` INT(10) UNSIGNED NULL DEFAULT NULL,
`user_report_fields` TEXT NULL,
`email_validation_key` VARCHAR(50) NULL DEFAULT NULL,
`last_gui_notification` INT(10) UNSIGNED NULL DEFAULT NULL,
`slave_to_multiuser` MEDIUMINT(8) UNSIGNED NULL DEFAULT NULL,
`active_multiuser` MEDIUMINT(8) UNSIGNED NULL DEFAULT NULL,
`facebook_id` DECIMAL(30,0) NULL DEFAULT NULL,
`google_id` DECIMAL(30,0) NULL DEFAULT NULL,
PRIMARY KEY (`user_id`),
UNIQUE INDEX `index_user_name` (`user_name`),
UNIQUE INDEX `index_user_external_id` (`external_id`, `domain_id`),
UNIQUE INDEX `facebook_id` (`facebook_id`),
UNIQUE INDEX `google_id` (`google_id`),
INDEX `FK_users_1` (`domain_id`),
INDEX `ifk_u_did_idx` (`domain_id`),
INDEX `ifk_u_sid_idx` (`status_id`),
INDEX `ifk_u_stm` (`slave_to_multiuser`),
INDEX `ifk_u_am` (`active_multiuser`),
CONSTRAINT `ifk_u_am` FOREIGN KEY (`active_multiuser`) REFERENCES `users` (`user_id`) ON UPDATE CASCADE ON DELETE SET NULL,
CONSTRAINT `ifk_u_did` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`domain_id`) ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT `ifk_u_sid` FOREIGN KEY (`status_id`) REFERENCES `users_status_codes` (`status_id`) ON UPDATE CASCADE ON DELETE SET NULL,
CONSTRAINT `ifk_u_stm` FOREIGN KEY (`slave_to_multiuser`) REFERENCES `users` (`user_id`) ON UPDATE CASCADE ON DELETE SET NULL
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=251
;
Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar