LAB - Make a LessonSchedule table with FK constraints Two tables are created:... 1 answer below »

  • 58 + Users Viewed

  • 14 + Downloaded Solutions

  • Washington, US Mostly Asked From

LAB - Make a LessonSchedule table with FK constraints

Two tables are created:

1.                  Horse with columns:

?      ID - integer, primary key

?      RegisteredName - variable-length string

2..                 Student with columns:

?      ID - integer, primary key

?      FirstName - variable-length string

?      LastName - variable-length string

Make the LessonSchedule table with columns:

?      HorseID - integer with range 0 to 65 thousand, not NULL, partial primary key, foreign key references Horse(ID)

?      StudentID - integer with range 0 to 65 thousand, foreign key references Student(ID)

?      LessonDateTime - date/time, not NULL, partial primary key

CREATE TABLE Horse (

          ID       SMALLINT UNSIGNED AUTO_INCREMENT,

          RegisteredName VARCHAR(15),

          PRIMARY KEY (ID)

);

CREATE TABLE Student (

          ID      SMALLINT UNSIGNED AUTO_INCREMENT,

          FirstName   VARCHAR(20),

          LastName               VARCHAR(30),

          PRIMARY KEY (ID)

);

-- Your SQL statements go here

Try Solving it with these steps:

These are AI-generated tips. For the verified answer, click “Solution.pdf.”

Here are some tips to create the LessonSchedule table with foreign key constraints:

  • Define Columns: Include HorseID, StudentID, and LessonDateTime as specified.
  • Set Data Types: Use appropriate data types for each column, ensuring they match referenced tables.
  • Primary Key: Designate HorseID and LessonDateTime as a composite primary key.
  • Foreign Keys: Establish foreign key constraints referencing Horse and Student tables.
  • Check Constraints: Ensure HorseID and StudentID are within the specified range and not NULL.
View More

1 Approved Answer

Expert Verified

Sameena N
3 Ratings (16 Votes)
Here’s the SQL code to create the `LessonSchedule` table with foreign key constraints referencing the `Horse` and `Student` tables. The `LessonSchedule` table uses a composite...

Recent Questions in Programming Languages

Plagiarism Checker

Submit your documents and get free Plagiarism report

Free Plagiarism Checker