中文网站
  Advanced Search
Read the latest Blogs from IT professionals in the field. Read and write community created documents. Need IT help? Ask our staff. Connect with your peers. Check our Tech Shop for posters, books and software tools. Home

5.1.8 Database Systems: Modifying the Database

1. QBE has facilities for modifying the database.

Deletion

1. We simply use D. instead of the P. operator. Whole tuples may be deleted, or only some columns.
2. Delete all of Smith's account records:

deposit bname account# cname balance
D.     Smith  

3. Delete the branch-city value for the SFU branch:

branch bname assets bcity
  SFU   D.

4. Delete all loans with loan numbers between 1300 and 1500:

borrow bname loan# cname amount
D.   _x    
conditions
_x = ( ≥1300 and ≤1500)

5. Delete all accounts at branches located in Burnaby:

deposit bname account# cname balance
D. _x      
branch bname assets bcity
  _x   Burnaby

Insertion

1. Insertion uses the I. operator.

2. To insert an account tuple for Smith:

deposit bname account# cname balance
I. SFU 9372 Smith 1200

3. If values are missing, nulls are inserted.

4. To provide all loan customers in the SFU branch with a $200 savings account:

deposit bname account# cname balance
I. SFU _x _y 200
borrow bname loan# cname amount
  SFU _x _y  

Updates

1. We can update individual attributes with the U. operator. Fields left blank are not changed.

2. To update the assets of the SFU branch to $10,000,000:

branch bname assets bcity
  SFU U.10000000  

3. To make interest payments of 5% on all balances:

deposit bname account# cname balance
U.      

_x * 1.05

_x

Database System Structure: