Banking

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

DROP TABLE IF EXISTS `banking`.

`account`;

CREATE TABLE `banking`.`account` (

`accountNo` int NOT NULL AUTO_INCREMENT,

`accountTitle` varchar(45) NOT NULL,

`address` varchar(50) DEFAULT NULL,

`accountType` enum('Savings','Current','Fixed Deposit') DEFAULT NULL,

`openingDate` date DEFAULT NULL,

`phone` char(15) DEFAULT NULL,

PRIMARY KEY (`accountNo`)

);

DROP TABLE IF EXISTS `banking`.`staff`;

CREATE TABLE `banking`.`staff` (

`staffId` int NOT NULL AUTO_INCREMENT,

`firstName` varchar(45) DEFAULT NULL,

`lastName` varchar(50) DEFAULT NULL,

`address` varchar(45) DEFAULT NULL,

`birthDate` date DEFAULT NULL,

`gender` enum('Female','Male') DEFAULT NULL,

`district` varchar(50) DEFAULT NULL,

PRIMARY KEY (`staffId`)

);

DROP TABLE IF EXISTS `banking`.`deposit`;

CREATE TABLE `banking`.`deposit` (

`Id` int NOT NULL AUTO_INCREMENT,

`Amount` double DEFAULT NULL,

`depositDate` datetime DEFAULT NULL,

`accountNo` int DEFAULT NULL,


`staffId` int DEFAULT NULL,

PRIMARY KEY (`Id`),

KEY `accountNo` (`accountNo`),

KEY `staffId` (`staffId`),

CONSTRAINT `deposit_ibfk_1` FOREIGN KEY (`accountNo`) REFERENCES `account` (`accountNo`),

CONSTRAINT `deposit_ibfk_2` FOREIGN KEY (`staffId`) REFERENCES `staff` (`staffId`)

);

DROP TABLE IF EXISTS `banking`.`withdraw`;

CREATE TABLE `banking`.`withdraw` (

`Id` int NOT NULL AUTO_INCREMENT,

`Amount` double DEFAULT NULL,

`withdrawDate` datetime DEFAULT NULL,

`accountNo` int DEFAULT NULL,

`staffId` int DEFAULT NULL,

PRIMARY KEY (`Id`),

KEY `accountNo` (`accountNo`),

KEY `staffId` (`staffId`),

CONSTRAINT `withdraw_ibfk_1` FOREIGN KEY (`accountNo`) REFERENCES `account` (`accountNo`) ON


DELETE RESTRICT ON UPDATE CASCADE,

CONSTRAINT `withdraw_ibfk_2` FOREIGN KEY (`staffId`) REFERENCES `staff` (`staffId`) ON DELETE


RESTRICT ON UPDATE CASCADE

);

You might also like