Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3842642
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:49:23+00:00 2026-05-19T15:49:23+00:00

I want to represent a timetable on a mysql database. I had the idea

  • 0

I want to represent a timetable on a mysql database.
I had the idea that I should have three tables:

  1. a classdetails table – containing class capacity, classroom name, etc.
  2. a class_sessions table with: start_time and end_time of session,
  3. a class_unit table with: the name of the course (MAT003. et.c)

there would also be appropriate foreign keys in the class_sessions table and class_unit table.

Eventually I want to be able to query for a ‘free’ class (one that does not have a class presently, at the time of running of the query) and return its name e.g (Room 5b)

Will the tables I have listed be sufficient for the query at hand?

Any ideas how to make this better will be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T15:49:23+00:00Added an answer on May 19, 2026 at 3:49 pm

    This does what you said, but I’m still not 100% confident that what you said is what you want. 🙂

    CREATE TABLE rooms (
      room_num VARCHAR(10) NOT NULL PRIMARY KEY
    );
    
    INSERT INTO rooms VALUES 
      ('5B'),
      ('5C'),
      ('5D');
    
    CREATE TABLE class_rooms (
      class VARCHAR(15) NOT NULL,
      room_num VARCHAR(10) NOT NULL,
      CONSTRAINT room_nm_fm_rooms FOREIGN KEY (room_num) REFERENCES rooms(room_num),
      PRIMARY KEY (class, room_num)
    );
    
    INSERT INTO class_rooms VALUES 
      ('Algebra', '5B'),
      ('Calculus','5C'),
      ('Discrete Math', '5C');
    

    Having done that, one way to get the room number that’s not in use is with a query using SELECT…WHERE…NOT IN. This probably isn’t the fastest, but in my experience it’s the easiest syntax to understand.

    SELECT room_num 
    FROM rooms 
    WHERE room_num NOT IN (SELECT room_num FROM class_rooms);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a complex JSON object that I want represent as C# class. I
I'm designing a database with three tables: user, game and (probably) register. I want
I have a table (several actually) that I want to get results from with
Let's say I want to represent \q (or any other particular backslash-escaped character). That
I have two tables, timetable and lesson_booking these are linked via timetable_id . timetable
I want to represent documents in a database. There are several different types of
If all tables I want to delete from have the column gamer_id can i
I have a POCO that is based off a normalized table. My question is
I want a datatype to represent a finite set of integers that can be
I want to define two endpoint that will represent two different interfaces <services> <service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.