0

/DROP TABLE STATEMENTS/
DROP TABLE BRANCH CASCADE CONSTRAINT PURGE;
DROP TABLE SCREEN CASCADE CONSTRAINT PURGE;
DROP TABLE SESSIONS CASCADE CONSTRAINT PURGE;
DROP TABLE MOVIE CASCADE CONSTRAINT PURGE;

/CREATE TABLE STATEMENT/

CREATE TABLE BRANCH(
BRANCHID CHAR(2)NOT NULL,
BRANCHNAME VARCHAR2(20),
BRANCHSUBURB VARCHAR2(15),
BRANCHPOSTCODE CHAR(4),
CONSTRAINT BRANCH_PK PRIMARY KEY(BRANCHID));

CREATE TABLE SCREEN(
SCREENID CHAR(2) NOT NULL,
BRANCHID CHAR(2) NOT NULL,
SCREENCAPACITY NUMBER(3),
CONSTRAINT SCREEN_PK PRIMARY KEY(BRANCHID,SCREENID),
CONSTRAINT SCREEN_FK1 FOREIGN KEY(BRANCHID)REFERENCES BRANCH(BRANCHID));

CREATE TABLE MOVIE(
MOVIEID CHAR(2) NOT NULL,
MOVIENAME VARCHAR(20),
MOVIEGENRE VARCHAR(20),
MOVIECLASSIFICATION VARCHAR(5),
CONSTRAINT MOVIE_PK PRIMARY KEY(MOVIEID));

CREATE TABLE SESSIONS(
SESSIONID CHAR(4),
BRANCHID CHAR(2)NOT NULL,
SCREENID CHAR(2)NOT NULL,
MOVIEID CHAR(2)NOT NULL,
SESSIONDATE DATE,
SESSIONPRICE NUMBER(4,2),
CONSTRAINT SESSIONS_PK PRIMARY KEY(SESSIONID),
CONSTRAINT SESSIONS_FK1 FOREIGN KEY(BRANCHID)REFERENCES BRANCH(BRANCHID),
CONSTRAINT SESSIONS_FK2 FOREIGN KEY(SCREENID)REFERENCES SCREEN(SCREENID),
CONSTRAINT SESSIONS_FK3 FOREIGN KEY(MOVIEID)REFERENCES MOVIE(MOVIEID));

can you guy help me out? i dont know why i have this error. i checked many time there seems no wrong spelling. plz show me why i have ERROR ORA - 02270.

show me how to fix it?
thank you very much

3
Contributors
2
Replies
24
Views
10 Months
Discussion Span
Last Post by Alec_2
0

You cannot set combined primary key CONSTRAINT SCREEN_PK PRIMARY KEY(BRANCHID,SCREENID)
The unique index may combine two (or more) fields eg UNIQUE(BRANCHID,SCREENID)

Edited by AndrisP

0

Most Probably when you have a missing Primary key is not defined from parent table. then It occurs

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.