create table Course (
courseId char(5),
subjectId char(4) not null,
courseNumber integer,
title varchar(50) not null,
numOfCredits integer,
primary key (courseId)
);


create table Student (
ssn char(9),
firstName varchar(25),
mi char(1),
lastName varchar(25),
birthDate date,
street varchar(25),
phone char(11),
zipCode char(5),
deptId char(4),
primary key (ssn)
);


create table Enrollment (
ssn char( 9),
courseId char( 5),
dateRegistered date,
grade char( 1),
primary key (ssn, courseId),
foreign key (ssn) references Student,
foreign key (courseId) references Course
);

the table "Enrollment" can not be created. where is the wrong?

Recommended Answers

All 3 Replies

Try:

foreign key (ssn) references Student(ssn),
foreign key (courseId) references Course(courseId)

thank you..its fine..

No problem! you can mark this thread as solved if that did the trick :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.