Question

Locked

SQL Constraints

By escape1486 ·
I found a tutorial online, but can't seem to get the answer. Are they all rejected since there's no data and there's a constraint in the user table?

Please help me with this. I would greatly appreciated it. Thanks.


Given the following table definitions:

CREATE TABLE USERS
(
USERID CHAR(5) PRIMARY KEY,
NAME VARCHAR(30),
RATING CHAR(1) CHECK (RATING IN (A, B,C,D)
)

CREATE TABLE ITEMS
(
ITEM_NO NUMBER PRIMARY KEY,
DESCRIPTION VARCHAR(50),
OFFERED_BY CHAR(5) REFERENCES USERS(USERID) ON UPDATE CASCADE ON DELETE CASCADE,
START_DATE DATETIME,
END_DATE DATETIME,
RESERVE_PRICE NUMBER
)

CREATE TABLE BIDS
(
USERID CHAR(5) REFERENCES USERS ON UPDATE CASCADE ON DELETE SET NULL,
ITEMNO NUMBER REFERENCES ITEMS(ITEM_NO) ON UPDATE CASCADE ON DELETE CASCADE,
BID NUMBER,
BID_DATE DATETIME,
PRIMARY KEY(USERID,ITEMNO,BID_DATE)
)

Directions: Indicate whether the statement is accepted or rejected; and if accepted indicate its effects. Evaluate each statement INDEPENDENTLY.

1) INSERT INTO ITEMS VALUES(1009, Red Bicycle,U01,1999-01-08, 1999-02-10, 30)
2) UPDATE ITEMS SET ITEMNO=1008 where ITEMNO=1001
3) DELETE FROM ITEMS WHERE ITEMNO=1005
4) INSERT INTO ITEMS VALUES(1010, Green Bicycle,U07,1999-01-08, 1999-02-10, 30)
5) UPDATE BIDS SET ITEMNO=1011 WHERE ITEMNO = 1001
6) DELETE FROM USERS WHERE USERID=U01
7) UPDATE ITEMS SET ITEMNO=1020 WHERE ITEMNO=1001
DELETE FROM BIDS WHERE BID > 1001

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

There seems to either be a bit missing

by Tony Hopkinson In reply to SQL Constraints

Or the questions were written by a total nipple head.
Possibly both.
The insert statements will fail unless the corresponding userids exists in users.

The updates and deletes won't because there's no data to delete or update.

Unless you've misread the question find another tutorial.

PS,
you can download sql server express 2005 free off ms, then you could learn by doing.

There will be a few hiccups syntax wise though.
it's quite likely to expect Green Bycycle as 'Green Bycyle'

and 19**-01-08 would = 1982

Back to Web Development Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums