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

  • SEARCH
  • Home
  • 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 8771341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:45:41+00:00 2026-06-13T17:45:41+00:00

I have finished designing the tables structures for a school course catalog. I am

  • 0

I have finished designing the tables structures for a school course catalog. I am using four tables majors, courses, course_hours, course_date. Below I have detailed the components of each table. Some of the tables will use indexing based on course_id. I am new with database and struggling with building these tables inside my database. How can I make these tables link together with using course_id? Or is there a better way to structure these tables for my purpose. If possible providing a query to create these tables will be great.

Hopefully I am using the righ type(int,varchar, text, etc) for my variables.

Example of table courses

id serial
course_name varchar
course_code varchar
description text

Example of table course_dates (using index)

id int
course_id int
year date
semester int

Example of table course_hours (using index)

id int
course_id int
hours int

Example of table majors (one to many relationship- index)

 major_id int
 course_id int 
 major_name varchar

So a populated database would contain the following:

Table courses

course_id course_code course_name       course_description
1     INF1000     Visual Studio I   "Basic programming"
2     INF1001     Visual Stuido II  "More programming"

Table course_dates (0 for spring, 1 for fall, 2 all year)

id course_id year semester
1  1         2012 0
2  1         2013 1
3  2         2013 1

Table course_hours

id course_id course_hours 
1  1         3 
2  1         4 
3  2         4 

Table majors

id course_id major_name
1  1         Computer Engineering 
2  1         Information Systems 
3  2         Network Administrator
  • 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-06-13T17:45:42+00:00Added an answer on June 13, 2026 at 5:45 pm

    i would do some restructuring:

    • add hours to courses and get rid of course_hours table (i don’t see
      any advantage to extracting hours to a seperate table)
    • course_dates might be better named as semester and the fields would be year (int) and semester (int)
    • majors should just explain each major so take course_id out and put it into a xref table
    • rename all tables to singular form (just a style preference)

    giving you a structure like:
    ERD

    edit: made it back to a mysql box. here’s the script for this structure. remember you might want to change charset and engine type as those can change per database, these are probably fine as is for default

    CREATE TABLE IF NOT EXISTS `course` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `name` varchar(100) NOT NULL,
      `code` varchar(10) NOT NULL,
      `description` varchar(500) DEFAULT NULL,
      `hours` tinyint(6) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
    
    CREATE TABLE IF NOT EXISTS `course_semester_xref` (
      `course_id` int(11) NOT NULL,
      `semester_id` int(11) NOT NULL,
      PRIMARY KEY (`course_id`,`semester_id`),
      KEY `semester_id` (`semester_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    CREATE TABLE IF NOT EXISTS `major` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `name` varchar(50) NOT NULL,
      `description` varchar(500) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
    
    CREATE TABLE IF NOT EXISTS `major_course_xref` (
      `major_id` int(11) NOT NULL,
      `course_id` int(11) NOT NULL,
      PRIMARY KEY (`major_id`,`course_id`),
      KEY `course_id` (`course_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    CREATE TABLE IF NOT EXISTS `semester` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `year` smallint(6) NOT NULL,
      `semester` tinyint(4) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
    
    ALTER TABLE `course_semester_xref`
      ADD CONSTRAINT `course_semester_xref_ibfk_2` FOREIGN KEY (`semester_id`) REFERENCES `semester` (`id`),
      ADD CONSTRAINT `course_semester_xref_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `course` (`id`);
    
    ALTER TABLE `major_course_xref`
      ADD CONSTRAINT `major_course_xref_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `course` (`id`),
      ADD CONSTRAINT `major_course_xref_ibfk_1` FOREIGN KEY (`major_id`) REFERENCES `major` (`id`);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Finished Designing my first Crystal Report using ASP.NET, I am Providing user
I've just finished designing a small android app and have now come to a
I have finished a rails project using i18n and now I need to pass
I have finished installing RabbitMQ using the following RPM http://www.rabbitmq.com/releases/rabbitmq-server/v2.7.1/rabbitmq-server-2.7.1-1.noarch.rpm i installed it like
I have a strange problem, I was designing a page and after I finished,
I have finished developing my java application using netbeans. Now I want to give
I have finished developing a big and heavy app. It is universal (for iPhone
I have finished the development of my app which uses Google Maps. During the
*Hey , I have finished developing my app In my iphone apps I have
Age old question! When you have finished developing and testing your ASP.Net web application,

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.