-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5cf220
commit 84e01f2
Showing
1 changed file
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
-- phpMyAdmin SQL Dump | ||
-- version 4.6.6deb5ubuntu0.5 | ||
-- https://www.phpmyadmin.net/ | ||
-- | ||
-- Host: localhost:3306 | ||
-- Generation Time: Dec 24, 2020 at 11:02 AM | ||
-- Server version: 5.7.32-0ubuntu0.18.04.1 | ||
-- PHP Version: 7.2.24-0ubuntu0.18.04.7 | ||
|
||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; | ||
SET time_zone = "+00:00"; | ||
|
||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8mb4 */; | ||
|
||
-- | ||
-- Database: `dbms` | ||
-- | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `admin` | ||
-- | ||
|
||
CREATE TABLE `admin` ( | ||
`password` varchar(50) NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
|
||
-- | ||
-- Dumping data for table `admin` | ||
-- | ||
|
||
INSERT INTO `admin` (`password`) VALUES | ||
('6bf6d01ad7acbb28a021a79ab444bd69'); | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `candidates` | ||
-- | ||
|
||
CREATE TABLE `candidates` ( | ||
`id` int(11) NOT NULL, | ||
`name` varchar(100) NOT NULL, | ||
`party` varchar(100) NOT NULL, | ||
`age` int(3) NOT NULL, | ||
`gender` varchar(10) NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
||
-- | ||
-- Dumping data for table `candidates` | ||
-- | ||
|
||
INSERT INTO `candidates` (`id`, `name`, `party`, `age`, `gender`) VALUES | ||
(1, 'Candidate A', 'Party 1', 45, 'Male'), | ||
(2, 'Candidate B', 'Party 2', 79, 'Female'), | ||
(3, 'Candidate C', 'Party 3', 39, 'Other'); | ||
|
||
-- | ||
-- Triggers `candidates` | ||
-- | ||
DELIMITER $$ | ||
CREATE TRIGGER `inserton` AFTER INSERT ON `candidates` FOR EACH ROW BEGIN | ||
insert into results(vc_id,name,party) values(new.id,new.name,new.party); | ||
END | ||
$$ | ||
DELIMITER ; | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `results` | ||
-- | ||
|
||
CREATE TABLE `results` ( | ||
`id` int(11) NOT NULL, | ||
`vc_id` int(11) NOT NULL, | ||
`name` varchar(100) NOT NULL, | ||
`party` varchar(100) NOT NULL, | ||
`vote_count` int(11) NOT NULL DEFAULT '0' | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `users` | ||
-- | ||
|
||
CREATE TABLE `users` ( | ||
`id` int(11) NOT NULL, | ||
`username` varchar(50) NOT NULL, | ||
`password` varchar(255) NOT NULL, | ||
`created_at` datetime DEFAULT CURRENT_TIMESTAMP | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `users_approval` | ||
-- | ||
|
||
CREATE TABLE `users_approval` ( | ||
`id` int(11) NOT NULL, | ||
`epic_no` varchar(20) NOT NULL, | ||
`email` varchar(255) NOT NULL, | ||
`username` varchar(50) NOT NULL, | ||
`password` varchar(255) NOT NULL, | ||
`age` int(3) NOT NULL, | ||
`gender` varchar(10) NOT NULL, | ||
`created_at` datetime DEFAULT CURRENT_TIMESTAMP | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `user_data` | ||
-- | ||
|
||
CREATE TABLE `user_data` ( | ||
`id` int(11) NOT NULL, | ||
`epic_no` varchar(20) NOT NULL, | ||
`email` varchar(255) NOT NULL, | ||
`username` varchar(255) NOT NULL, | ||
`age` int(11) NOT NULL, | ||
`gender` varchar(10) NOT NULL, | ||
`approved_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`voted` int(2) NOT NULL DEFAULT '0' | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
|
||
-- | ||
-- Indexes for dumped tables | ||
-- | ||
|
||
-- | ||
-- Indexes for table `candidates` | ||
-- | ||
ALTER TABLE `candidates` | ||
ADD PRIMARY KEY (`id`), | ||
ADD KEY `id` (`id`), | ||
ADD KEY `name` (`name`), | ||
ADD KEY `party` (`party`); | ||
|
||
-- | ||
-- Indexes for table `results` | ||
-- | ||
ALTER TABLE `results` | ||
ADD PRIMARY KEY (`id`), | ||
ADD KEY `vc_id` (`vc_id`), | ||
ADD KEY `name` (`name`), | ||
ADD KEY `party` (`party`); | ||
|
||
-- | ||
-- Indexes for table `users` | ||
-- | ||
ALTER TABLE `users` | ||
ADD PRIMARY KEY (`id`), | ||
ADD UNIQUE KEY `username` (`username`); | ||
|
||
-- | ||
-- Indexes for table `users_approval` | ||
-- | ||
ALTER TABLE `users_approval` | ||
ADD PRIMARY KEY (`id`), | ||
ADD UNIQUE KEY `username` (`username`), | ||
ADD UNIQUE KEY `username_2` (`username`); | ||
|
||
-- | ||
-- Indexes for table `user_data` | ||
-- | ||
ALTER TABLE `user_data` | ||
ADD PRIMARY KEY (`id`), | ||
ADD UNIQUE KEY `username` (`username`); | ||
|
||
-- | ||
-- AUTO_INCREMENT for dumped tables | ||
-- | ||
|
||
-- | ||
-- AUTO_INCREMENT for table `candidates` | ||
-- | ||
ALTER TABLE `candidates` | ||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; | ||
-- | ||
-- AUTO_INCREMENT for table `results` | ||
-- | ||
ALTER TABLE `results` | ||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; | ||
-- | ||
-- AUTO_INCREMENT for table `users` | ||
-- | ||
ALTER TABLE `users` | ||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; | ||
-- | ||
-- AUTO_INCREMENT for table `users_approval` | ||
-- | ||
ALTER TABLE `users_approval` | ||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; | ||
-- | ||
-- AUTO_INCREMENT for table `user_data` | ||
-- | ||
ALTER TABLE `user_data` | ||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; | ||
-- | ||
-- Constraints for dumped tables | ||
-- | ||
|
||
-- | ||
-- Constraints for table `results` | ||
-- | ||
ALTER TABLE `results` | ||
ADD CONSTRAINT `results_ibfk_1` FOREIGN KEY (`vc_id`) REFERENCES `candidates` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | ||
ADD CONSTRAINT `results_ibfk_2` FOREIGN KEY (`name`) REFERENCES `candidates` (`name`) ON DELETE CASCADE ON UPDATE CASCADE, | ||
ADD CONSTRAINT `results_ibfk_3` FOREIGN KEY (`party`) REFERENCES `candidates` (`party`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |