text: -- phpMyAdmin SQL Dump
  -- version 4.7.0
  -- https://www.phpmyadmin.net/
  --
  -- Host: 127.0.0.1
  -- Generation Time: Oct 08, 2017 at 09:22 PM
  -- Server version: 10.1.26-MariaDB
  -- PHP Version: 7.1.8
  
  SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  SET AUTOCOMMIT = 0;
  START TRANSACTION;
  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: `db_librarymanagement`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `tbl_books`
  --
  
  CREATE TABLE `tbl_books` (
    `book_id` int(11) NOT NULL,
    `ISBN` varchar(250) NOT NULL,
    `availability` varchar(250) NOT NULL,
    `title` varchar(250) NOT NULL,
    `author` varchar(250) NOT NULL,
    `description` text NOT NULL,
    `edition` varchar(250) NOT NULL,
    `edition_year` varchar(250) NOT NULL,
    `date_created` date NOT NULL,
    `date_updated` date NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `tbl_book_borrower`
  --
  
  CREATE TABLE `tbl_book_borrower` (
    `id` int(11) NOT NULL,
    `book_id` int(11) NOT NULL,
    `borrower_id` int(11) NOT NULL,
    `date_returned` date NOT NULL,
    `expected_return_date` date NOT NULL,
    `date_borrowed` date NOT NULL,
    `notes` text NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `tbl_book_category`
  --
  
  CREATE TABLE `tbl_book_category` (
    `book_id` int(11) NOT NULL,
    `category_id` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `tbl_book_overdue`
  --
  
  CREATE TABLE `tbl_book_overdue` (
    `book_borrower_ref_id` int(11) NOT NULL,
    `computed_fee` float NOT NULL,
    `paid` float NOT NULL,
    `balance` float NOT NULL,
    `notes` text NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `tbl_borrower`
  --
  
  CREATE TABLE `tbl_borrower` (
    `borrower_id` int(11) NOT NULL,
    `title` varchar(250) NOT NULL,
    `firstname` varchar(250) NOT NULL,
    `lastname` varchar(250) NOT NULL,
    `birthday` date NOT NULL,
    `gender` varchar(100) NOT NULL,
    `address 1` varchar(250) NOT NULL,
    `address 2` varchar(250) NOT NULL,
    `address 3` varchar(250) NOT NULL,
    `postal_code` varchar(100) NOT NULL,
    `town` varchar(100) NOT NULL,
    `country` varchar(100) NOT NULL,
    `mobile_number` varchar(100) NOT NULL,
    `email_address` varchar(100) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `tbl_category`
  --
  
  CREATE TABLE `tbl_category` (
    `category_id` int(11) NOT NULL,
    `title` varchar(250) NOT NULL,
    `description` text NOT NULL,
    `date_created` date NOT NULL,
    `date_updated` date NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `tbl_profile`
  --
  
  CREATE TABLE `tbl_profile` (
    `profile_id` int(11) NOT NULL,
    `firstname` varchar(250) NOT NULL,
    `lastname` varchar(250) NOT NULL,
    `email_address` varchar(250) NOT NULL,
    `phone_number` varchar(250) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `tbl_user`
  --
  
  CREATE TABLE `tbl_user` (
    `id` int(11) NOT NULL,
    `username` varchar(250) NOT NULL,
    `password` varchar(250) NOT NULL,
    `first_secret_question` varchar(250) NOT NULL,
    `first_secret_answer` varchar(250) NOT NULL,
    `second_secret_question` varchar(250) NOT NULL,
    `second_secret_answer` varchar(250) NOT NULL,
    `third_secret_question` varchar(250) NOT NULL,
    `third_secret_answer` varchar(250) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `tbl_user_profile`
  --
  
  CREATE TABLE `tbl_user_profile` (
    `user_id` int(11) NOT NULL,
    `profile_id` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indexes for table `tbl_books`
  --
  ALTER TABLE `tbl_books`
    ADD PRIMARY KEY (`book_id`);
  
  --
  -- Indexes for table `tbl_book_borrower`
  --
  ALTER TABLE `tbl_book_borrower`
    ADD PRIMARY KEY (`id`),
    ADD KEY `borrower_id` (`borrower_id`);
  
  --
  -- Indexes for table `tbl_book_category`
  --
  ALTER TABLE `tbl_book_category`
    ADD KEY `book_id` (`book_id`),
    ADD KEY `tbl_book_category_ibfk_2` (`category_id`);
  
  --
  -- Indexes for table `tbl_book_overdue`
  --
  ALTER TABLE `tbl_book_overdue`
    ADD KEY `book_borrower_ref_id` (`book_borrower_ref_id`);
  
  --
  -- Indexes for table `tbl_borrower`
  --
  ALTER TABLE `tbl_borrower`
    ADD PRIMARY KEY (`borrower_id`);
  
  --
  -- Indexes for table `tbl_category`
  --
  ALTER TABLE `tbl_category`
    ADD PRIMARY KEY (`category_id`);
  
  --
  -- Indexes for table `tbl_profile`
  --
  ALTER TABLE `tbl_profile`
    ADD PRIMARY KEY (`profile_id`);
  
  --
  -- Indexes for table `tbl_user`
  --
  ALTER TABLE `tbl_user`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `tbl_user_profile`
  --
  ALTER TABLE `tbl_user_profile`
    ADD KEY `profile_id` (`profile_id`),
    ADD KEY `user_id` (`user_id`);
  
  --
  -- AUTO_INCREMENT for dumped tables
  --
  
  --
  -- AUTO_INCREMENT for table `tbl_books`
  --
  ALTER TABLE `tbl_books`
    MODIFY `book_id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `tbl_book_borrower`
  --
  ALTER TABLE `tbl_book_borrower`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `tbl_borrower`
  --
  ALTER TABLE `tbl_borrower`
    MODIFY `borrower_id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `tbl_category`
  --
  ALTER TABLE `tbl_category`
    MODIFY `category_id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `tbl_profile`
  --
  ALTER TABLE `tbl_profile`
    MODIFY `profile_id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `tbl_user`
  --
  ALTER TABLE `tbl_user`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- Constraints for dumped tables
  --
  
  --
  -- Constraints for table `tbl_book_borrower`
  --
  ALTER TABLE `tbl_book_borrower`
    ADD CONSTRAINT `tbl_book_borrower_ibfk_1` FOREIGN KEY (`borrower_id`) REFERENCES `tbl_book_borrower` (`id`);
  
  --
  -- Constraints for table `tbl_book_category`
  --
  ALTER TABLE `tbl_book_category`
    ADD CONSTRAINT `tbl_book_category_ibfk_1` FOREIGN KEY (`book_id`) REFERENCES `tbl_books` (`book_id`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `tbl_book_category_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `tbl_category` (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE;
  
  --
  -- Constraints for table `tbl_book_overdue`
  --
  ALTER TABLE `tbl_book_overdue`
    ADD CONSTRAINT `tbl_book_overdue_ibfk_1` FOREIGN KEY (`book_borrower_ref_id`) REFERENCES `tbl_book_borrower` (`id`);
  
  --
  -- Constraints for table `tbl_user_profile`
  --
  ALTER TABLE `tbl_user_profile`
    ADD CONSTRAINT `tbl_user_profile_ibfk_1` FOREIGN KEY (`profile_id`) REFERENCES `tbl_profile` (`profile_id`),
    ADD CONSTRAINT `tbl_user_profile_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `tbl_user` (`id`);
  COMMIT;
  
  /*!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 */;
  