SQL: How to Create Table with a time condition?

I am currently learning SQL for University and my teacher asked me to create a table for the following scheme:

Class: Room, StartTime (automatically add 90mins), Day, ClassName, optionalComment

With the following conditions:

  • one class can have multiple occurrences
  • a Room can only be taken up by one class at a time
  • a Room can be occupied by different classes at different times

I am just stuck with this one. I was thinking about constraints, but not really figuring anything out.

Can someone maybe push my mind in the right direction?

Thank you!

EDIT: This is what I got so far, as I said - I am very stuck.

create table class (
    room varchar(10) not null
    day varchar(100) not null
    className varchar(255) not null
    optionalComment varchar(255)
    startTime time )


Read more here: https://stackoverflow.com/questions/64882083/sql-how-to-create-table-with-a-time-condition

Content Attribution

This content was originally published by Valanx at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: