Sie sind auf Seite 1von 2

Online Toy Store Management System

Refer the given Table structure and Data to Solve the problems.
Create tables Toy_Store and Toy_details and Toy_store_rel with following specifications.
All constraints should have proper names.

TOY_STORE
Column Name Data Type Constraints
TOY_STORE_ID NUMBER(3) PRIMARY KEY
TOY_STORE_NAME VARCHAR2(30) NOT NULL
CITY VARCHAR2(30) Delhi, if not provided
PHONENUMBER NUMBER(10) UNIQUE AND NOT NULL
STORE_OPENING_TIME TIMESTAMP After 8 AM
STORE_CLOSING_TIME TIMESTAMP Before 10 PM

TOY_DTLS
* Add all the constraints for TOY_DTLS after table creation by using alter.
Column Name Data Type Constraints
TOY_ID NUMBER(4) PRIMARY KEY
TOY_NAME VARCHAR2(30) NOT NULL, UNIQUE
TOY_PRICE NUMBER(7,2) > 10 , Mandatory
DISCOUNT_PERCENT NUMBER(5,2) < 90
AGEGROUP NUMBER(3) By default 5
TOY_RATING NUMBER(1) BETWEEN 1 TO 5
CATEGORY CHAR(1) Allowed I / O / B for Indoor/Outdoor and Both
TOY_PIC BLOB(16M)

TOY_REL
* Add IN_STOCK and AVAILABLE_QTY columns after table creation
Column Name Data Type Constraints
TOY_ID NUMBER(4) PRIMARY KEY.FOREIGN KEY(Toy_Dtls)
TOY_STORE_ID NUMBER(3) PRIMARY KEY,FOREIGN KEY(Toy_Store)
IN_STOCK CHAR(1) By default N, allowed Y/N
AVAILABLE_QTY NUMBER(3) Default 0

TCS Internal
TOY_STORE_ID TOY_STORE_NAME CITY PHONENUMBER STORE_OPENING_TIME STORE_CLOSING_TIME
2014-04-01 21:42:05
1 Kid's Cave Delhi 9912312312 2014-04-01 09:10:12
2 Kid's Corner Mumbai 9912312321 2014-04-01 09:00:00 2014-04-01 20:00:00
3 Play and Grow Mumbai 9912312301 2014-04-01 09:00:00 2014-04-01 20:00:00
4 Puzzles and More Delhi 8112312301 2014-04-01 08:15:00 2014-04-01 20:00:00
5 Uncle Sam Toys Den Delhi 8112312310 2014-04-01 08:01:00 2014-04-01 20:00:00
6 Mickey Toys Delhi 8221312345 2014-04-01 09:00:00 2014-04-01 20:00:00

TOY_ID TOY_NAME TOY_PRICE DISCOUNTPERC AGEGROUP TOY_RATING CATEGORY TOY_PIC


1 Bat 500 5
2 Ball 50 5 o
3 Brainvita 250 2 10 5I
4 Scrabble 100 80 15 1I
5 Snakes and Ladders 40 0 5 2I
6 Chess 50 5 10 4I
7 Basket Ball 150 5 10 4o
8 Volley Ball 150 5 10 4o
9 Ping pong Ball 30 2 5 2b
10 Skates 450 10 3o
11 Racing _--_ cars 50 5 3I

TOY_ID TOY_STORE_ID IN_STOCK AVAILABLE_QTY


1 1N 0
2 2Y 4
3 2Y 6
1 4N 0
3 4Y 12
4 4Y 16

Insert data in TOY_REL as per your choice, minimum 15 rows should be present.
Write SQL for following cases after reading all questions carefully.
1. Set auto commit option as false. Issue commit only when specified.
2. Create sequences for TOY_STORE and TOY_DTLS.
3. Insert data as mentioned above in TOY_STORE and TOY_DTLS. The primary key values should come from the sequence.
4. Insert data in TOY_REL as per your choice, minimum 15 rows should be present. Each time after inserting 5 rows save the
transactions to that point as S1.Issue commit.
5. Update IN_Stock value in TOY_REL to 'N' and AVAILABLE_QTY to 0 where either Toy_store_id or Toy_id is equal to 1. Save
till here as S2.
6. Delete all entries from TOY_REL for Mickey Toys and for racing cars. Save till here as S3.
7. Rollback to Save point S1 and then to S2. Which roll back was successful and why?
8. Increase price by 5% for all Toys for Store Puzzles and More. Issue Rollback. Till which transaction has it roll backed?
9. Set auto commit as true. Update all store opening and closing dates as current date and Time as shown above.
10. Add column SOLD_QUANTITY to table TOY_REL with data type as number and size 3.
11. Add constraint Default value AS 0 for SOLD_QUANTITY.
12. Modify the size of column to Number(5) for SOLD_QUANTITY.
13. Update SOLD_QUANTITY column as the same value as its row position when all the rows are displayed from table (i.e. Sold
quantity= 1 for row position 1 and so on..)
14. Remove the constraint for default 0 value on column SOLD_QUANTITY.
15. Remove the column SOLD_QUANTITY.
16. Add cascade on delete behaviour to table TOY_REL. (Hint: May include more than one step).
17. Truncate table toystore. (Hint: May include more than one step).

TCS Internal

Das könnte Ihnen auch gefallen