Advertisement
muhidins

db_pilkasis

Mar 20th, 2021
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.92 KB | None | 0 0
  1. CREATE TABLE IF NOT EXISTS `election` (
  2.   `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  3.   `type` VARCHAR(5) NULL,
  4.   `voter_id` INT UNSIGNED NULL,
  5.   `candidate_id` INT UNSIGNED NULL,
  6.   `time` VARCHAR(45) NULL,
  7.   PRIMARY KEY (`id`),
  8.   INDEX `candidate_id` (`candidate_id` ASC),
  9.   CONSTRAINT `fk_election_candidate`
  10.     FOREIGN KEY (`candidate_id`)
  11.     REFERENCES `candidates` (`id`)
  12.     ON DELETE NO ACTION
  13.     ON UPDATE NO ACTION)
  14. ENGINE = InnoDB;
  15.  
  16.  
  17. -- -----------------------------------------------------
  18. -- Table `users`
  19. -- -----------------------------------------------------
  20. CREATE TABLE IF NOT EXISTS `users` (
  21.   `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  22.   `username` VARCHAR(45) NOT NULL,
  23.   `password` VARCHAR(65) NOT NULL,
  24.   `name` VARCHAR(75) NULL,
  25.   `gender` CHAR(1) NOT NULL DEFAULT 'M',
  26.   `position` VARCHAR(45) NULL,
  27.   `email` VARCHAR(100) NULL,
  28.   `phone` VARCHAR(15) NULL,
  29.   `active` CHAR(1) NOT NULL,
  30.   `photo` VARCHAR(100) NULL,
  31.   PRIMARY KEY (`id`),
  32.   UNIQUE INDEX `username_UNIQUE` (`username` ASC))
  33. ENGINE = InnoDB;
  34.  
  35.  
  36. -- -----------------------------------------------------
  37. -- Table `teachers`
  38. -- -----------------------------------------------------
  39. CREATE TABLE IF NOT EXISTS `teachers` (
  40.   `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  41.   `username` VARCHAR(45) NOT NULL,
  42.   `password` VARCHAR(65) NOT NULL,
  43.   `name` VARCHAR(75) NULL,
  44.   `gender` CHAR(1) NOT NULL DEFAULT 'M',
  45.   `pob` VARCHAR(45) NULL,
  46.   `dob` DATE NULL,
  47.   `teach` VARCHAR(50) NULL,
  48.   `email` VARCHAR(100) NULL,
  49.   `phone` VARCHAR(15) NULL,
  50.   `active` CHAR(1) NOT NULL,
  51.   `candidate_id` INT UNSIGNED NULL,
  52.   `photo` VARCHAR(100) NULL,
  53.   PRIMARY KEY (`id`),
  54.   UNIQUE INDEX `username_UNIQUE` (`username` ASC),
  55.   INDEX `candidate_id` (`candidate_id` ASC),
  56.   CONSTRAINT `fk_teachers_candidates`
  57.     FOREIGN KEY (`candidate_id`)
  58.     REFERENCES `candidates` (`id`)
  59.     ON DELETE CASCADE
  60.     ON UPDATE CASCADE)
  61. ENGINE = InnoDB;
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement