교수님은 우리 데이터베이스 클래스에 대해이 코드에서 일부 공백을 채우기를 원했습니다. 나는 그 일을 제대로하고 있다고 생각하지만, 주제에 관해서 막 시작했는지 확신 할 수 없다. 누군가가 나에게 어떤 방향이나 도움이되는 근원을 줄 수 있다면 어디에서 다섯 번째 제약 (IC5)으로 시작해야할지 모른다.(Oracle) SQL DDL - 무결성 제약
SPOOL ddl.out
SET ECHO ON
--
-- Author:
--
-- IMPORTANT: use the names IC-1, IC-2, etc. as given below.
-- --------------------------------------------------------------------
DROP TABLE Orders CASCADE CONSTRAINTS;
DROP TABLE OrderLine CASCADE CONSTRAINTS;
--
CREATE TABLE Orders
(
orderNum INTEGER PRIMARY KEY,
priority CHAR(10) NOT NULL,
cost INTEGER NOT NULL,
/*
IC1: The priority is one of: high, medium, or low
*/
CHECK priority=('high' OR 'medium' OR 'low'),
/*
IC2: The cost of a high priority order is above 2000.
*/
CHECK priority='high' AND cost>2000,
/*
IC3: The cost of a medium priority order is between 800 and 2200 (inclusive).
*/
CHECK priority='medium' AND cost BETWEEN 800 AND 2200,
/*
IC4: The cost of a low priority order is less than 1000.
*/
CHECK priority='low' AND cost<1000,
);
--
--
CREATE TABLE OrderLine
(
orderNum INTEGER,
lineNum INTEGER,
item CHAR (10) NOT NULL,
quantity INTEGER,
PRIMARY KEY (orderNum, lineNum),
/*
IC5: Every order line must belong to an order in the Order table.
Also: if an order is deleted then all its order lines must be deleted.
IMPORTANT: DO NOT declare this IC as DEFERRABLE.
*/
<<< YOUR SQL CODE GOES HERE >>>
);
--
-- ----------------------------------------------------------------
-- TESTING THE SCHEMA
-- ----------------------------------------------------------------
INSERT INTO Orders VALUES (10, 'high', 2400);
INSERT INTO Orders VALUES (20, 'high', 1900);
INSERT INTO Orders VALUES (30, 'high', 2100);
INSERT INTO Orders VALUES (40, 'medium', 700);
INSERT INTO Orders VALUES (50, 'low', 1100);
INSERT INTO Orders VALUES (60, 'low', 900);
SELECT * from Orders;
IC1이 짧아 질 수있다; IC2, IC3, IC4는 모두 잘못되었습니다. 지정한 값 이외의 다른 값은 허용하지 않습니다. –