-- phpMyAdmin SQL Dump
-- version 4.9.5
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: May 19, 2021 at 02:26 PM
-- Server version: 10.4.14-MariaDB-cll-lve
-- PHP Version: 7.2.34

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: `u857788680_hospital`
--

-- --------------------------------------------------------

--
-- Table structure for table `bill`
--

CREATE TABLE `bill` (
  `billno` char(8) COLLATE utf8mb4_unicode_ci NOT NULL,
  `patientid` char(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nurseno` char(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `billdate` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `bill`
--

INSERT INTO `bill` (`billno`, `patientid`, `nurseno`, `billdate`) VALUES
('10000001', 'p07', '458', '2019-10-26'),
('10000002', 'p01', '458', '2019-10-26'),
('10000003', 'p02', '458', '2019-10-26'),
('10000004', 'p01', '458', '2019-10-26'),
('10000005', 'p03', '543', '2019-10-26'),
('10000006', 'p01', '458', '2019-10-26');

-- --------------------------------------------------------

--
-- Table structure for table `billitem`
--

CREATE TABLE `billitem` (
  `billno` char(8) COLLATE utf8mb4_unicode_ci NOT NULL,
  `itemname` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `qty` int(11) NOT NULL,
  `unitprice` decimal(7,2) NOT NULL,
  `lineno` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `billitem`
--

INSERT INTO `billitem` (`billno`, `itemname`, `qty`, `unitprice`, `lineno`) VALUES
('10000001', 'Room', 1, '1000.50', 1),
('10000002', 'Room', 5, '5000.00', 1),
('10000002', 'Expensive medicine', 6, '10000.00', 2),
('10000002', 'Fluffy pillows', 2, '500.00', 3),
('10000002', 'Ping machine', 1, '10000.00', 4),
('10000003', 'Room', 5, '5000.00', 1),
('10000003', 'Expensive medicine', 6, '10000.00', 2),
('10000004', 'Room', 5, '5000.00', 1),
('10000004', 'Expensive medicine', 6, '10000.00', 2),
('10000005', 'Room', 5, '5000.00', 1),
('10000005', 'Expensive medicine', 6, '10000.00', 2),
('10000005', 'Fluffy pillows', 2, '500.00', 3),
('10000005', 'Ping machine', 1, '10000.00', 4),
('10000006', 'Room', 5, '5000.00', 1),
('10000006', 'Expensive medicine', 6, '10000.00', 2);

-- --------------------------------------------------------

--
-- Table structure for table `doctor`
--

CREATE TABLE `doctor` (
  `staffno` char(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `docposition` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
  `specialty` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `doctor`
--

INSERT INTO `doctor` (`staffno`, `docposition`, `specialty`) VALUES
('110', 'Consultant', 'Cardiac'),
('131', 'Consultant', 'Orthopaedic'),
('156', 'Registrar', NULL),
('174', 'Registrar', NULL),
('178', 'Registrar', NULL),
('200', 'Consultant', 'Paediatric'),
('231', 'Consultant', 'Orthopaedic'),
('232', 'Consultant', 'Geriatric'),
('268', 'House Officer', NULL),
('385', 'Registrar', NULL),
('389', 'House Officer', NULL),
('462', 'House Officer', NULL),
('493', 'House Officer', NULL),
('517', 'Registrar', NULL),
('603', 'House Officer', NULL),
('606', 'House Officer', NULL),
('614', 'House Officer', NULL),
('680', 'House Officer', NULL),
('723', 'Registrar', NULL),
('736', 'Registrar', NULL),
('784', 'Consultant', 'Gynaecology'),
('857', 'House Officer', NULL),
('862', 'House Officer', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `nurse`
--

CREATE TABLE `nurse` (
  `staffno` char(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `wardno` char(3) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `nurse`
--

INSERT INTO `nurse` (`staffno`, `wardno`) VALUES
('192', 'w2'),
('360', 'w2'),
('362', 'w2'),
('424', 'w2'),
('535', 'w2'),
('617', 'w2'),
('823', 'w2'),
('153', 'w3'),
('206', 'w3'),
('283', 'w3'),
('373', 'w3'),
('607', 'w3'),
('700', 'w3'),
('126', 'w4'),
('218', 'w4'),
('256', 'w4'),
('345', 'w4'),
('349', 'w4'),
('523', 'w4'),
('765', 'w4'),
('789', 'w4'),
('315', 'w5'),
('458', 'w5'),
('744', 'w5'),
('838', 'w5'),
('840', 'w5'),
('113', 'w7'),
('222', 'w7'),
('543', 'w7');

-- --------------------------------------------------------

--
-- Table structure for table `patient`
--

CREATE TABLE `patient` (
  `patientid` char(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `doctorno` char(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `wardno` char(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `patient`
--

INSERT INTO `patient` (`patientid`, `doctorno`, `wardno`, `name`) VALUES
('p01', '231', 'w5', 'Bell'),
('p02', '110', 'w2', 'Robinson'),
('p03', '110', 'w7', 'Edmonds'),
('p04', '232', 'w3', 'Anarkali'),
('p05', '110', 'w2', 'Pettit'),
('p06', '231', 'w4', 'Smith'),
('p07', '784', 'w5', 'Tennent'),
('p08', '200', 'w4', 'James'),
('p09', '131', 'w3', 'Kay'),
('p10', '231', 'w4', 'Jones'),
('p11', '110', 'w7', 'Benyon'),
('p12', '232', 'w2', 'Hook'),
('p13', '200', 'w4', 'Woodward'),
('p14', '131', 'w3', 'Bird'),
('p15', '231', 'w4', 'Harris'),
('p16', '110', 'w7', 'Samuel'),
('p17', '131', 'w3', 'Rosewood'),
('p18', '110', 'w2', 'Toppaz'),
('p19', '784', 'w5', 'Cumberland'),
('p20', '231', 'w5', 'Roland'),
('p21', '200', 'w4', 'Cornish'),
('p22', '232', 'w2', 'Parsi'),
('p23', '232', 'w3', 'Smith'),
('p24', '110', 'w7', 'Docker'),
('p25', '131', 'w3', 'Diamond'),
('p26', '232', 'w2', 'Colbert'),
('p27', '231', 'w5', 'Ozbekof'),
('p28', '784', 'w5', 'Kraft'),
('p29', '231', 'w4', 'Jones'),
('p30', '110', 'w2', 'Parkinson');

-- --------------------------------------------------------

--
-- Table structure for table `rcptdetail`
--

CREATE TABLE `rcptdetail` (
  `rcptno` int(11) NOT NULL,
  `billno` char(8) COLLATE utf8mb4_unicode_ci NOT NULL,
  `lineno` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `rcptdetail`
--

INSERT INTO `rcptdetail` (`rcptno`, `billno`, `lineno`) VALUES
(1, '10000002', 1),
(1, '10000002', 2),
(2, '10000002', 3),
(3, '10000003', 1),
(3, '10000003', 2),
(4, '10000002', 4),
(4, '10000004', 1),
(4, '10000004', 2),
(5, '10000005', 1),
(6, '10000006', 1),
(6, '10000006', 2);

-- --------------------------------------------------------

--
-- Table structure for table `receipt`
--

CREATE TABLE `receipt` (
  `rcptno` int(11) NOT NULL,
  `rcptdate` date NOT NULL,
  `patientid` char(3) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `receipt`
--

INSERT INTO `receipt` (`rcptno`, `rcptdate`, `patientid`) VALUES
(1, '2014-10-10', 'p01'),
(2, '2014-10-11', 'p01'),
(3, '2014-10-12', 'p02'),
(4, '2014-10-12', 'p02'),
(5, '2014-10-12', 'p01'),
(6, '2014-10-12', 'p02');

-- --------------------------------------------------------

--
-- Table structure for table `staff`
--

CREATE TABLE `staff` (
  `staffno` char(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `staffname` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `staff`
--

INSERT INTO `staff` (`staffno`, `staffname`) VALUES
('110', 'Liversage'),
('113', 'Hutt'),
('126', 'Sesonske'),
('131', 'Kalsi'),
('153', 'Cooke'),
('156', 'Hollis'),
('174', 'Gibson'),
('178', 'Paxton'),
('192', 'Wilkie'),
('200', 'Tamblin'),
('206', 'Reay'),
('218', 'Peters'),
('222', 'Ullman'),
('231', 'Ansell'),
('232', 'Shine'),
('256', 'Locke'),
('268', 'Dowse'),
('283', 'Sahdev'),
('315', 'Aslam'),
('345', 'Copleston'),
('349', 'Connor'),
('360', 'Sykes'),
('362', 'Colman'),
('373', 'Vine'),
('385', 'Zorkoczy'),
('389', 'Wright'),
('424', 'Slee'),
('458', 'Galvin'),
('462', 'Webster'),
('493', 'Rampton'),
('517', 'Goss'),
('523', 'Descartes'),
('535', 'Aris'),
('543', 'Maier'),
('603', 'Nolan'),
('606', 'Orchard'),
('607', 'Hughes'),
('614', 'Hill'),
('617', 'Patel'),
('680', 'Wolfe'),
('700', 'Birch'),
('723', 'Asif'),
('736', 'Palmer'),
('744', 'Winch'),
('765', 'Fleming'),
('784', 'Franklin'),
('789', 'Warnock'),
('823', 'Sadiq'),
('838', 'Brown'),
('840', 'Leverett'),
('857', 'Neville'),
('862', 'Franklin');

-- --------------------------------------------------------

--
-- Table structure for table `supervises`
--

CREATE TABLE `supervises` (
  `relid` int(11) NOT NULL,
  `issupervisor` char(1) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nurseno` char(3) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `supervises`
--

INSERT INTO `supervises` (`relid`, `issupervisor`, `nurseno`) VALUES
(5, 'Y', '113'),
(16, 'Y', '113'),
(4, 'Y', '126'),
(6, 'Y', '126'),
(9, 'Y', '126'),
(10, 'Y', '126'),
(14, 'Y', '126'),
(20, 'Y', '126'),
(21, 'Y', '126'),
(1, 'N', '153'),
(2, 'N', '192'),
(3, 'N', '206'),
(4, 'N', '218'),
(5, 'N', '222'),
(6, 'N', '256'),
(7, 'N', '283'),
(8, 'N', '315'),
(9, 'N', '345'),
(10, 'N', '349'),
(11, 'N', '360'),
(2, 'Y', '362'),
(11, 'Y', '362'),
(13, 'Y', '362'),
(15, 'Y', '362'),
(18, 'Y', '362'),
(24, 'Y', '362'),
(12, 'N', '373'),
(13, 'N', '424'),
(8, 'Y', '458'),
(19, 'Y', '458'),
(22, 'Y', '458'),
(23, 'Y', '458'),
(14, 'N', '523'),
(15, 'N', '535'),
(16, 'N', '543'),
(17, 'N', '607'),
(18, 'N', '617'),
(1, 'Y', '700'),
(3, 'Y', '700'),
(7, 'Y', '700'),
(12, 'Y', '700'),
(17, 'Y', '700'),
(19, 'N', '744'),
(20, 'N', '765'),
(21, 'N', '789'),
(24, 'N', '823'),
(22, 'N', '838'),
(23, 'N', '840');

-- --------------------------------------------------------

--
-- Table structure for table `ward`
--

CREATE TABLE `ward` (
  `wardno` char(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  `maxbeds` int(11) NOT NULL,
  `wardname` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `ward`
--

INSERT INTO `ward` (`wardno`, `maxbeds`, `wardname`) VALUES
('w10', 0, 'Empty ward'),
('w2', 20, 'Wessex'),
('w3', 15, 'Anglia'),
('w4', 20, 'Lakes'),
('w5', 15, 'Dales'),
('w7', 12, 'Pennines');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `bill`
--
ALTER TABLE `bill`
  ADD PRIMARY KEY (`billno`),
  ADD KEY `fk_billpatient` (`patientid`),
  ADD KEY `fk_billnurse` (`nurseno`);

--
-- Indexes for table `billitem`
--
ALTER TABLE `billitem`
  ADD PRIMARY KEY (`billno`,`lineno`),
  ADD UNIQUE KEY `billno` (`billno`,`itemname`);

--
-- Indexes for table `doctor`
--
ALTER TABLE `doctor`
  ADD PRIMARY KEY (`staffno`);

--
-- Indexes for table `nurse`
--
ALTER TABLE `nurse`
  ADD PRIMARY KEY (`staffno`),
  ADD KEY `fk_nurseward` (`wardno`);

--
-- Indexes for table `patient`
--
ALTER TABLE `patient`
  ADD PRIMARY KEY (`patientid`),
  ADD KEY `fk_patientdoctor` (`doctorno`),
  ADD KEY `fk_patientward` (`wardno`);

--
-- Indexes for table `rcptdetail`
--
ALTER TABLE `rcptdetail`
  ADD PRIMARY KEY (`billno`,`lineno`),
  ADD KEY `fk_rd_rcpt` (`rcptno`);

--
-- Indexes for table `receipt`
--
ALTER TABLE `receipt`
  ADD PRIMARY KEY (`rcptno`),
  ADD KEY `fk_rcptpatient` (`patientid`);

--
-- Indexes for table `staff`
--
ALTER TABLE `staff`
  ADD PRIMARY KEY (`staffno`);

--
-- Indexes for table `supervises`
--
ALTER TABLE `supervises`
  ADD PRIMARY KEY (`relid`,`issupervisor`),
  ADD KEY `fk_supernurse` (`nurseno`);

--
-- Indexes for table `ward`
--
ALTER TABLE `ward`
  ADD PRIMARY KEY (`wardno`);

--
-- Constraints for dumped tables
--

--
-- Constraints for table `bill`
--
ALTER TABLE `bill`
  ADD CONSTRAINT `fk_billnurse` FOREIGN KEY (`nurseno`) REFERENCES `nurse` (`staffno`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_billpatient` FOREIGN KEY (`patientid`) REFERENCES `patient` (`patientid`) ON UPDATE CASCADE;

--
-- Constraints for table `billitem`
--
ALTER TABLE `billitem`
  ADD CONSTRAINT `fk_billitem_bill` FOREIGN KEY (`billno`) REFERENCES `bill` (`billno`);

--
-- Constraints for table `doctor`
--
ALTER TABLE `doctor`
  ADD CONSTRAINT `fk_doctorstaff` FOREIGN KEY (`staffno`) REFERENCES `staff` (`staffno`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `nurse`
--
ALTER TABLE `nurse`
  ADD CONSTRAINT `fk_nursestaff` FOREIGN KEY (`staffno`) REFERENCES `staff` (`staffno`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_nurseward` FOREIGN KEY (`wardno`) REFERENCES `ward` (`wardno`) ON UPDATE CASCADE;

--
-- Constraints for table `patient`
--
ALTER TABLE `patient`
  ADD CONSTRAINT `fk_patientdoctor` FOREIGN KEY (`doctorno`) REFERENCES `doctor` (`staffno`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_patientward` FOREIGN KEY (`wardno`) REFERENCES `ward` (`wardno`) ON UPDATE CASCADE;

--
-- Constraints for table `rcptdetail`
--
ALTER TABLE `rcptdetail`
  ADD CONSTRAINT `fk_rd_billitem` FOREIGN KEY (`billno`,`lineno`) REFERENCES `billitem` (`billno`, `lineno`),
  ADD CONSTRAINT `fk_rd_rcpt` FOREIGN KEY (`rcptno`) REFERENCES `receipt` (`rcptno`);

--
-- Constraints for table `receipt`
--
ALTER TABLE `receipt`
  ADD CONSTRAINT `fk_rcptpatient` FOREIGN KEY (`patientid`) REFERENCES `patient` (`patientid`);

--
-- Constraints for table `supervises`
--
ALTER TABLE `supervises`
  ADD CONSTRAINT `fk_supernurse` FOREIGN KEY (`nurseno`) REFERENCES `nurse` (`staffno`) ON UPDATE CASCADE;
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 */;
