What's new

Help Patulong sql mga boss

SyntaxError-

Eternal Poster
Joined
Oct 9, 2016
Posts
605
Solutions
8
Reaction
1,132
Points
383
ano mali ko rito mga boss?

SQL:
create table Professors(
    professor_id int not null primary key,
    first_name varchar(25),
    last_name varchar(25),
    contact_number varchar (12),
    major varchar(25),
    department varchar(75)
    );

create table ClassSchedules(
    class_ID int not null primary key,
    course_id int foreign key references classsched_course(course_id),
    subject varchar,
    schedule varchar,
    room_id int foreign key references classsched_room(room_id),
    professor_id int foreign key references classsched_prof(professor_id)
    );

create table Students(
    student_id int not null primary key,
    first_name varchar,
    last_name varchar,
    contact_number varchar (12),
    address varchar(75),
    course_id int foreign key references student_course(course_id)
    );

create table Rooms(
    room_id int not null primary key,
    room_name varchar,
    building varchar
    );

create table Courses(
    course_id int  not null primary key,
    title varchar,
    description text,
    department varchar
    );


1681531895494.png


1681531848241.png
 

Attachments

Last edited:
Based on the provided code, it seems that there are missing tables that are being referenced in the foreign key constraints of some of the tables.

For example, in the ClassSchedules table, the course_id column is referencing a table called classsched_course and the room_id column is referencing a table called classsched_room. However, these tables are not created in the code provided.

Also, in the Students table, the course_id column is referencing a table called student_course, which is not created in the code as well.

To resolve this issue, you need to make sure that all the tables that are being referenced in the foreign key constraints are created before the tables that are referencing them.

Here's an updated code that includes the missing tables:

Code:
create table Courses(
    course_id int  not null primary key,
    title varchar,
    description text,
    department varchar
);

create table Rooms(
    room_id int not null primary key,
    room_name varchar,
    building varchar
);

create table Professors(
    professor_id int not null primary key,
    first_name varchar(25),
    last_name varchar(25),
    contact_number varchar (12),
    major varchar(25),
    department varchar(75)
);

create table ClassSchedules(
    class_ID int not null primary key,
    course_id int foreign key references Courses(course_id),
    subject varchar,
    schedule varchar,
    room_id int foreign key references Rooms(room_id),
    professor_id int foreign key references Professors(professor_id)
);

create table StudentCourses(
    course_id int not null primary key,
    course_name varchar,
    department varchar
);

create table Students(
    student_id int not null primary key,
    first_name varchar,
    last_name varchar,
    contact_number varchar (12),
    address varchar(75),
    course_id int foreign key references StudentCourses(course_id)
);

Note: I also added a StudentCourses table to provide a reference for the course_id column in the Students table. You can modify this table as needed to fit your data model.
 
Based on the provided code, it seems that there are missing tables that are being referenced in the foreign key constraints of some of the tables.

For example, in the ClassSchedules table, the course_id column is referencing a table called classsched_course and the room_id column is referencing a table called classsched_room. However, these tables are not created in the code provided.

Also, in the Students table, the course_id column is referencing a table called student_course, which is not created in the code as well.

To resolve this issue, you need to make sure that all the tables that are being referenced in the foreign key constraints are created before the tables that are referencing them.

Here's an updated code that includes the missing tables:

Code:
create table Courses(
    course_id int  not null primary key,
    title varchar,
    description text,
    department varchar
);

create table Rooms(
    room_id int not null primary key,
    room_name varchar,
    building varchar
);

create table Professors(
    professor_id int not null primary key,
    first_name varchar(25),
    last_name varchar(25),
    contact_number varchar (12),
    major varchar(25),
    department varchar(75)
);

create table ClassSchedules(
    class_ID int not null primary key,
    course_id int foreign key references Courses(course_id),
    subject varchar,
    schedule varchar,
    room_id int foreign key references Rooms(room_id),
    professor_id int foreign key references Professors(professor_id)
);

create table StudentCourses(
    course_id int not null primary key,
    course_name varchar,
    department varchar
);

create table Students(
    student_id int not null primary key,
    first_name varchar,
    last_name varchar,
    contact_number varchar (12),
    address varchar(75),
    course_id int foreign key references StudentCourses(course_id)
);

Note: I also added a StudentCourses table to provide a reference for the course_id column in the Students table. You can modify this table as needed to fit your data model.
ganon pala yon! maraming salamat ginoong robot
 

Similar threads

Back
Top