Einzelnen Beitrag anzeigen

Benutzerbild von stOrM
stOrM

Registriert seit: 7. Jun 2003
Ort: Mülheim an der Ruhr
436 Beiträge
 
Delphi 10.3 Rio
 
#4

AW: Benutzerrechte MySQL erstellen Tabellenseitig

  Alt 7. Apr 2016, 07:41
Also so wüde es zumindest erst einmal funktionieren, nur ist das überhaupt korrekt? Irgendwie bezweifel ich das gerade ganz stark!

Code:
CREATE TABLE `roles` (
  `role_id` int(11) NOT NULL AUTO_INCREMENT,
  `role_name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`role_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Code:
CREATE TABLE `roles_rights` (
  `user_id` int(11) NOT NULL,
  `role_id` int(11) NOT NULL,
  `module_name` varchar(254) COLLATE utf8_unicode_ci DEFAULT NULL,
  `mp_read` int(1) DEFAULT NULL,
  `mp_write` int(1) DEFAULT NULL,
  `mp_delete` int(1) DEFAULT NULL,
  `mp_view` int(1) DEFAULT NULL,
  PRIMARY KEY (`user_id`,`role_id`),
  KEY `role_id` (`role_id`),
  CONSTRAINT `roles_rights_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`),
  CONSTRAINT `roles_rights_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `roles` (`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Code:
CREATE TABLE `users` (
  `user_id` int(11) NOT NULL AUTO_INCREMENT,
  `first_name` varchar(45) CHARACTER SET utf8 NOT NULL,
  `middle_name` varchar(45) CHARACTER SET utf8 DEFAULT NULL,
  `last_name` varchar(45) CHARACTER SET utf8 NOT NULL,
  `login_name` varchar(254) CHARACTER SET utf8 NOT NULL,
  `email` varchar(45) CHARACTER SET utf8 NOT NULL,
  `password` varchar(254) CHARACTER SET utf8 NOT NULL,
  `created_at` date NOT NULL,
  `updated_at` date DEFAULT NULL,
  `deleted_at` date DEFAULT NULL,
  `active` int(1) NOT NULL,
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  Mit Zitat antworten Zitat