Hola a todos!!
Estoy realizando el modelado de datos sobre los siguientes puntos
- Aplicar Permisos a nivel de usuario (a un usuario particular se la dar los permisos agregar, editar,etc)
- Aplicar Permisos a nivel de grupo (las cuentas podrian tener tipo a b c .... entonces a este tipo de cuentas se agruparia para formar el grupo letras, entonces aplicaria los permisosal grupo letras y asi evitaria darle permisos por cada cuenta)
- Aplicar Permisos a nivel de Proyecto (las cuentas a b c pertenecen al proyecto "lenguaje", la misma logica de grupos)
- Normalizacion
DROP TABLE IF EXISTS `groups`;
CREATE TABLE IF NOT EXISTS `groups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`description` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `projects`;
CREATE TABLE IF NOT EXISTS `projects` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`description` varchar(255) NOT NULL,
`active` char(1) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `typeaccount`;
CREATE TABLE IF NOT EXISTS `typeaccount` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`description` varchar(255) NOT NULL,
`active` char(1) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `accounts`;
CREATE TABLE IF NOT EXISTS `accounts` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`obs` varchar(255) NOT NULL,
`active` char(1) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`typeaccount_id` int(10) unsigned NOT NULL,
`project_id` int(10) unsigned NOT NULL,
`groups_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `accounts_typeaccount_id_foreign` (`typeaccount_id`),
KEY `accounts_project_id_foreign` (`project_id`),
KEY `fk_accounts_groups1_idx` (`groups_id`),
CONSTRAINT `accounts_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `accounts_typeaccount_id_foreign` FOREIGN KEY (`typeaccount_id`) REFERENCES `typeaccount` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_accounts_groups1` FOREIGN KEY (`groups_id`) REFERENCES `groups` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `users`;
CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(60) NOT NULL,
`failed_attemps` varchar(255) NOT NULL,
`last_login` datetime NOT NULL,
`active` char(1) NOT NULL,
`remember_token` varchar(100) DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`profile_id` int(10) unsigned NOT NULL,
`typeuser_id` int(11) NOT NULL,
`area_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `useraccount`;
CREATE TABLE IF NOT EXISTS `useraccount` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`ua_new` char(1) NOT NULL,
`ua_edit` char(1) NOT NULL,
`ua_del` char(1) NOT NULL,
`ua_show` char(1) NOT NULL,
`ua_xls` char(1) NOT NULL,
`ua_pdf` char(1) NOT NULL,
`ua_delete` char(1) NOT NULL,
`account_id` int(10) unsigned NOT NULL,
`user_id` int(10) unsigned NOT NULL,
`project_id` int(10) unsigned NOT NULL,
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`groups_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `useraccount_account_id_foreign` (`account_id`),
KEY `useraccount_user_id_foreign` (`user_id`),
KEY `useraccount_project_id_foreign` (`project_id`),
KEY `fk_useraccount_groups1_idx` (`groups_id`),
CONSTRAINT `fk_useraccount_groups1` FOREIGN KEY (`groups_id`) REFERENCES `groups` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `useraccount_account_id_foreign` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `useraccount_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `useraccount_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
imagen
https://mega.nz/#!9UF3VK6I!lUzDb7j8hjw0UNXxpDiA1OquQTUFx881Y5Vr0lCEPuM
Me ayudaria muchos sus observaciones y/o alguna sugerencia para mejorar la estructura de la basededatos
Gracias de antemano !