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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:18:41+00:00 2026-05-24T21:18:41+00:00

I am designing a MYSQL database for online tutoring website Let’s say, I have:

  • 0

I am designing a MYSQL database for online tutoring website

Let’s say, I have:

  • faculty table with (faculty_id, faculty name)
  • subject table with (subject_id, subject name)
  • student table with (student_id, student name)
  • class table with (class_id, faculty_id, student_id, subject_id)

Now I would like to run SQL queries on the class table to find out all students enrolled with a particular faculty & under a particular subject for which I have:

$sql=("SELECT * 
       FROM class 
       WHERE (faculty_id = '" . mysql_real_escape_string($_POST['faculty_id']) . "') 
       and (subject_id = '" . mysql_real_escape_string($_POST['subject_id']) . "')");

However, I can’t seem to figure out how to retrieve student name, faculty name, and subject name instead of just the faculty_id, student_id & subject_id stored in the class table.

Is there some type of SCHEMA and foreign key relations I need to create which automatically link the ID numbers to their respective rows in the respective tables so i can run UPDATE, DELETE, and INSERT queries based on these ID numbers?

Am I missing something important here? I’m not an expert in DB design. Please help.

  • 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-24T21:18:41+00:00Added an answer on May 24, 2026 at 9:18 pm

    That’s not something that happens in your schema, it’s something that you do when you query the database.

    To get information from a related table, you JOIN that table.

    SELECT
      class.class_id,
      student.name AS `student_name`,
      faculty.name AS `faculty_name`,
      subject.name AS `subject_name`
    FROM
      class
    INNER JOIN
      student
    ON
      student.student_id = class.student_id
    INNER JOIN
      faculty
    ON
      faculty.faculty_id = class.faculty_id
    INNER JOIN
      subject
    ON
      subject.subject_id = class.subject_id
    WHERE
      class.faculty_id = ?
    AND
      class.subject_id = ?
    

    You’ll have to replace any column names with what they actually are (your examples had spaces in them, so I’m sure those aren’t the real names), and put your PHP code with the post values where the ? are… good time to read up on PDO parameterized queries too.

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

Sidebar

Related Questions

While I'm designing a MySQL database for a dating website, I have come with
I'm designing a mySQL DB and I'm having the following issue: Say I have
I am designing the database (MySQL) in which I have two tables Employees and
I am designing a website which will query a simple MySQL database using AJAX
I am designing a online website (PHP, HTML and MySQL) with one of the
I am designing an SQL database (accessed via PHP/MySQL) and have questions about designing
I have trouble defining a trigger for a MySQL database. I want to change
When designing user table what would be the must have fields from the security/user
I am currently in the process of designing myself a database driven website. The
I have a question regarding database connection in PHP and MySQL. I wonder if

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.