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 3662626
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:26:16+00:00 2026-05-19T01:26:16+00:00

I have a table Classes, which stores data on different college classes (a unique

  • 0

I have a table Classes, which stores data on different college classes (a unique Class_ID and Department, Course, etc.).

Some Classes are cross-listed with multiple names. For example, the same class might be cross listed as HIST-204 (History) and AAST-103 (African American Studies). There can be more than 2 cross-listings for a class.

I’d like to store cross-listings properly, so that when students search for a class’s textbooks (stored in Class_Books table) using any of its possible cross-listings, they are shown the required books. It is not important whether students know about other cross-listings when they make a search, only that they get the books for that course.

I’m thinking of doing this by storing a Cross_List_ID in Classes, which would indicate that a given class is just a cross listing of an existing one, whose Class_ID would be stored in that field. Then I would only need to store the required book (in Class_Books) for the Class_ID that was cross listed. Then when students enter a class in the search, I’d make sure to include all books required for the Cross_List_ID. If you agree that this is the way to go, I’d be interested in how you’d set up that query (to get the class-books for the class_id entered, as well as its cross-listing).

One other option would seem to be storing Class_Books data for every cross listing.. I don’t want to do this method because the raw Class and Class-Book data which I upload to the database doesn’t lend itself to this, because there are separate files for each, and only one of the cross-listings is linked to a Book in the Class-Book file. Also, even if this method were easily feasible, it would use up more database space.

I’m open to other options if you disagree with my Cross_Listing_ID approach. Like I said, if you agree with that approach then help me make a query!

Note: Structure of Class-Books is just Class_ID, Book_ID

  • 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-19T01:26:17+00:00Added an answer on May 19, 2026 at 1:26 am

    If you have to pick between the two go with the first option. You don’t want to have ostensibly duplicate entries in class books. That can cause all sorts of problems for you.

    Update Since you want Class ID to be in the where clause I’ve updated it.

    As for the query this is how I would search for books

    SELECT DISTINCT books.*
    FROM
        classes main
        LEFT JOIN classes crosslinked
        ON main.Class_id = crosslinked.cross_link_class_id
        LEFT JOIN class_books books
        ON main.class_id =  books.class_id
    WHERE
        main.class_id= 252
        OR
        crossLinked.class_id= 252 
    

    But you should take ijw’s point. It would be much better to just have a class_names table that’s associated with the class. It would be a bit cleaner. Then you don’t have to do logic like : if cross_link_class_id is not null then don’t allow students to register for it, a professor can’t teach a class that has a null for cross_link_class_id.., after all you wouldn’t want to accidentally overbook a class or double the number of classes a professor was being recorded as teaching

    Here’s how it would be done with a separate class names table.

    SELECT DISTINCT books.*
    FROM
        classes 
        --LEFT JOIN class_names names
        --ON main.Class_id = names.Class_id 
        LEFT JOIN class_books books
        ON main.class_id =  books.class_id
    WHERE
       clases.class_id  = 252 
    

    Notice the OR statement is gone and no funny self join (which can confuse people) and the aforementioned logic on empty cross_link_class_id is gone.

    Note: I’ve taken some liberties with the query e.g the literal string would be replaced with a parameter. You wouldn’t select * but use the actual field names.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following 3 rails classes, which are all stored in one table,
I have a few classes, such as those that outline database table structure or
I have table rows of data in html being filled from a CGI application.
I have the situation where i use GIS software which stores the information about
I have 2 classes with a LINQ association between them i.e.: Table1: Table2: ID
I have table inside a div tab. The table has 40 rows in it
I have table with 50 entries (users with such details like Name Surname Location
Imagine I have table like this: id:Product:shop_id 1:Basketball:41 2:Football:41 3:Rocket:45 4:Car:86 5:Plane:86 Now, this
While trying to use LINQ to SQL I encountered several problems. I have table
I have a table with more than a millon rows. This table is used

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.