Dbms 1
Dbms 1
REG.NO: 22BRS1112
B) NAME: account
FIELDS DATATYPE
account_no varchar2(11)
branch_name varchar2(30)
balance number(8)
C) NAME: customer
FIELD DATATYPE
customer_id varchar2(11)
customer_name varchar2(20)
customer_street varchar2(15)
customer_city varchar2(15)
D) NAME: depositor
FIELD DATATYPE
customer_id varchar2(11)
account_no varchar2(11)
F) NAME: borrower
FIELDS DATATYPE
customer_id varchar2(11)
loan_no varcahr2(4)
4. Add primary keys to all the tables for the specified attributes
A) NAME: branch
FIELDS DATATYPE
branch_name varchar2(30) primary key
branch_city varchar2(30)
assets number(8,2)
C) NAME: customer
FIELD DATATYPE
customer_id varchar2(11) primary key
customer_name varchar2(20)
customer_street varchar2(15)
customer_city varchar2(15)
5. Add foreign keys to the following tables for the specified attributes with
mentioned
reference table
B) NAME: account
FIELDS DATATYPE
account_no varchar2(11) primary key
branch_name varchar2(30) references branch(branch_name)
balance number(8)
DESCRIBE account_22brs1112;
C) NAME: depositor
FIELD DATATYPE
customer_id varchar2(11)references customer (customer_id)
account_no varchar2(11)references account (account_no)
D) NAME: loan
FIELDS DATATYPE
loan_no varchar2(4) primary key
branch_name varchar2(30) references branch(branch_name)
(Create constraint with constraint name)
amount number(8,2)
DESCRIBE loan_22brs1112;
DESCRIBE loan_22brs1112;
7.Set loan_no attribute of borrower table as foreign key with cascade
deletion,
which refers to loan table loan_no column.
DESCRIBE borrower_22brs1112;
8.Add foreign key for the customer_id of borrower table which refers to
customer table with
constraint name.
5. customer
CUSTOMER_ID CUSTOMER_NAME CUSTOMER_STREET
CUSTOMER_CITY
c_01 smith north rye
c_02 turner putnam stamford
c_03 johnson alma palo alto
c_04 curry north rye
c_05 jones main harrisdon
c_06 adoms spring pittsfield
c_07 lindsay park pittsfield
c_08 hayes main harrison
c_09 williams nassau Princeton
DESCRIBE customer_22brs1112;
6. borrower
CUSTOMER_ID LOAN_NO
c_01 1_11
c_01 1_23
c_03 1_93
c_05 1_17
c_03 1_16
c_05 1_14
CREATE TABLE paydetails (emp_id INT, dept_id INT, basic INT, deductions INT, additions
INT, DOJ DATE, PRIMARY KEY (emp_id, dept_id), FOREIGN KEY (emp_id)
REFERENCES employee(emp_id), FOREIGN KEY (dept_id) REFERENCES
department(dept_id));
DESCRIBE paydetails;
d) payroll(emp_id : integer, pay_date: date)
CREATE TABLE payroll (emp_id INT, pay_date DATE, PRIMARY KEY (emp_id, pay_date),
FOREIGN KEY (emp_id) REFERENCES employee(emp_id));
DESCRIBE payroll;