-- Drop the existing table if it exists
DROP TABLE IF EXISTS `account_operations`;
-- Create the table with the InnoDB engine and foreign key constraints
CREATE TABLE IF NOT EXISTS `account_operations` (
`op_id` int(11) DEFAULT NULL,
`acc_op_id` int(11) NOT NULL,
`emp_id` int(11) DEFAULT NULL,
`acc_no` int(11) DEFAULT NULL,
`change_in_balance` float DEFAULT NULL,
`transaction_type` int(11) DEFAULT NULL,
PRIMARY KEY (`acc_op_id`),
FOREIGN KEY (`emp_id`) REFERENCES `employees`(`emp_id`),
FOREIGN KEY (`acc_no`) REFERENCES `accounts`(`acc_no`),
FOREIGN KEY (`transaction_type`) REFERENCES `transaction_types`(`type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Drop the existing table if it exists
DROP TABLE IF EXISTS `account_holder`;
-- Create the table with the InnoDB engine and foreign key constraints
CREATE TABLE IF NOT EXISTS `account_holder` (
`holder_id` int(11) NOT NULL,
`customer_id` varchar(13) DEFAULT NULL,
`acc_no` int(11) DEFAULT NULL,
`branch_id` int(11) DEFAULT NULL,
PRIMARY KEY (`holder_id`),
FOREIGN KEY (`customer_id`) REFERENCES `customer`(`customer_id`),
FOREIGN KEY (`acc_no`) REFERENCES `account`(`acc_no`),
FOREIGN KEY (`branch_id`) REFERENCES `branch`(`branch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Drop the existing table if it exists
DROP TABLE IF EXISTS `account_type`;
-- Create the table with the InnoDB engine
CREATE TABLE IF NOT EXISTS `account_type` (
`acc_typ_id` int(11) NOT NULL,
`acc_typ_name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`acc_typ_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Drop the existing table if it exists
DROP TABLE IF EXISTS `acc_currency_typ`;
-- Create the table with the InnoDB engine
CREATE TABLE IF NOT EXISTS `acc_currency_typ` (
`curr_id` int(11) NOT NULL,
`curr_name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`curr_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Drop the existing table if it exists
DROP TABLE IF EXISTS `acount_holder_type`;
-- Create the table with the InnoDB engine
CREATE TABLE IF NOT EXISTS `acount_holder_type` (
`typ_id` int(11) NOT NULL,
`typ_name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`typ_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Drop the existing table if it exists
DROP TABLE IF EXISTS `branch`;
-- Create the table with the InnoDB engine
CREATE TABLE IF NOT EXISTS `branch` (
`B_id` int(11) NOT NULL,
`B_name` varchar(10) DEFAULT NULL,
`b_address` varchar(30) DEFAULT NULL,
PRIMARY KEY (`B_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Drop the existing table if it exists
DROP TABLE IF EXISTS `customer`;
-- Create the table with the InnoDB engine
CREATE TABLE IF NOT EXISTS `customer` (
`cnic` varchar(13) NOT NULL,
`cus_name` varchar(20) DEFAULT NULL,
`present_address` varchar(30) DEFAULT NULL,
PRIMARY KEY (`cnic`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Drop the existing table if it exists
DROP TABLE IF EXISTS `designation`;
-- Create the table with the InnoDB engine
CREATE TABLE IF NOT EXISTS `designation` (
`d_id` int(11) NOT NULL,
`d_name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`d_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Drop the existing table if it exists
DROP TABLE IF EXISTS `employee`;
-- Create the table with the InnoDB engine
CREATE TABLE IF NOT EXISTS `employee` (
`emp_id` int(11) NOT NULL,
`emp_nm` varchar(20) DEFAULT NULL,
`cnic` varchar(13) DEFAULT NULL,
PRIMARY KEY (`emp_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Drop the existing table if it exists
DROP TABLE IF EXISTS `employement`;
-- Create the table with the InnoDB engine
CREATE TABLE IF NOT EXISTS `employement` (
`employment_id` int(11) NOT NULL,
`emp_id` int(11) DEFAULT NULL,
`branch_id` int(11) DEFAULT NULL,
`d_id` int(11) DEFAULT NULL,
`status_of_desig` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`employment_id`),
FOREIGN KEY (`emp_id`) REFERENCES `employee`(`emp_id`),
FOREIGN KEY (`branch_id`) REFERENCES `branch`(`B_id`),
FOREIGN KEY (`d_id`) REFERENCES `designation`(`d_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Drop the existing table if it exists
DROP TABLE IF EXISTS `operations`;
-- Create the table with the InnoDB engine
CREATE TABLE IF NOT EXISTS `operations` (
`op_id` int(11) NOT NULL,
`op_name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`op_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Drop the existing table if it exists
DROP TABLE IF EXISTS `op_log`;
-- Create the table with the InnoDB engine
CREATE TABLE IF NOT EXISTS `op_log` (
`old_balance` int(11) DEFAULT NULL,
`log_id` int(11) NOT NULL,
`acc` int(11) NOT NULL,
`emp` int(11) NOT NULL,
`op` int(11) NOT NULL,
PRIMARY KEY (`log_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Drop the existing table if it exists
DROP TABLE IF EXISTS `trnasation_type`;
-- Create the table with the InnoDB engine
CREATE TABLE IF NOT EXISTS `trnasation_type` (
`t_id` int(11) NOT NULL,
`t_name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`t_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;