1. Transaction Proposal
BEGIN TRANSACTION
INSERT INTO Buy_Sell
VALUES (23, 5, 1, 3, 150,000)
UPDATE CLIENT
SET BALANCE = 200,000 – 150,000
WHERE CLIENT_ID = 1
UPDATE CLIENT
SET BALANCE = 75,000 + 150,000
WHERE CLIENT_ID = 3
COMMIT;
This transaction would update clients’ accounts by adding/subtracting funds from it in regards to
a purchased/sold property. BALANCE is an added attribute, along with TRANS_VALUE.
The same code, using the attribute names:
BEGIN TRANSACTION
INSERT INTO Buy_Sell
VALUES (TRANS_ID, PROP_ID, BUYER_ID, SELLER_ID, TRANS_VALUE)
UPDATE CLIENT
SET BALANCE = BALANCE - TRANS_VALUE
WHERE CLIENT_ID = 1
UPDATE CLIENT
SET BALANCE = BALANCE + TRANS_VALUE
WHERE CLIENT_ID = 3
COMMIT;
Query Optimization/Analyzing Proposal
SELECT PROP_ID, PROP_BEDROOM, PROP_CITY
FROM group1.1property
WHERE PROP_CITY = ‘CHICAGO’ AND PROP_BEDROOM>=4;
Can be optimized as
SELECT PROP_ID, PROP_BEDROOM, PROP_CITY
FROM group1.1property
WHERE PROP_BEDROOM>=4 AND PROP_CITY = ‘CHICAGO’;
In the event there are only a handful of properties with more than four bedrooms.
Suggested Security Measure
A method of encryption can be used to protect the client information in the event of a security
breach.
2. Group Assumptions:
A client can be a buyer, seller, or both.
A buyer is a client but each client may or may not be a buyer.
A seller is a client but each client may or may not be a seller.
A buyer can buy many properties, but needs at least one.
A buy sell transaction involves one and only one buyer.
A seller can sell many properties, but needs at least one.
A buy sell transaction involves only one seller.
A client can make many referrals.
A referral is made by exactly one client.
A referral is made for one transaction.
A transaction may or may not have referral.
An agency can list many properties.
A property may or may not be listed by any other external agencies.
An area may consist of many properties.
Each property is in exactly one area.
An area may consist of many schools.
Each school is in exactly one area.
A property may be advertised many times.
Each advertisement is done for exactly one property.
An outlet may advertise many advertisements.
Each advertisement is done in exactly one outlet.
A property can either be a condominium or a single family.