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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:44:23+00:00 2026-06-02T10:44:23+00:00

Imagine we have a phpadmin database and we have a table for students and

  • 0

Imagine we have a phpadmin database and we have a table for students and student_music and student_friend student_friend_music. Does this make sense performance wise to have four tables? or do you think we need to have three tables for students students_friends student_music and table for music. How does facebook stores friends relationship in it’s database?

Other thing is that I designed the data base for both. I don’t know if I see any difference but I think once the users increase one would beat other performance wise?

So my question concerns the performances of querying:
Is this better to have more tables or
Can we have duplicates.

Do you know any good book, tutorial or reference I can study to know about relational data bases in Php my admin and mysql.

Update:
Table Student can have many to many relation with itself.
Table Music has Many to Many with the student as well.

Student id Student_friend  Music id     STUDENT_MUSIC     
  A      1      1-3         YT    1          1  3
  B      2      2-3         RU    2          2  3
  C      3                  PI    3          3  1
                                             3  2

So I am using something called Data Mapper in code igniter which causing me a headache but this sounds like a structure I am thinking now.

  • 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-02T10:44:24+00:00Added an answer on June 2, 2026 at 10:44 am

    Check out this link for a mysql introduction and the wikipedia article on relational databases. Read about tables, primary and foreign keys. Before worrying about performance you need to address the structure of your database.

    Try (One-to-Many:A student can own many pieces of music and have one friend):

    CREATE TABLE Student(
        id INT NOT NULL AUTO_INCREMENT, 
        PRIMARY KEY(id),
        first_name VARCHAR(30),
        last_name VARCHAR(30),
        friend_id INT)
    
    CREATE TABLE Music(
        id INT NOT NULL AUTO_INCREMENT, 
        PRIMARY KEY(id),
        music_title VARCHAR(30),
        music_student_id INT)
        FOREIGN KEY (music_student_id) REFERENCES Student(id)
                      ON DELETE CASCADE
    

    Or Try (Many-to-Many:Many students can own many pieces of music and have many friends):

    CREATE TABLE Student(
        id INT NOT NULL AUTO_INCREMENT, 
        PRIMARY KEY(id),
        first_name VARCHAR(30),
        last_name VARCHAR(30))
        FOREIGN KEY (id) 
        REFERENCES StudentMusic (Student_id)
        ON DELETE CASCADE
    
    CREATE TABLE Music(
        id INT NOT NULL AUTO_INCREMENT, 
        PRIMARY KEY(id),
        music_title VARCHAR(30),
        FOREIGN KEY (id) 
        REFERENCES StudentMusic (Music_id)
        ON DELETE CASCADE
    
    CREATE TABLE StudentMusic (
        Student_id INT NOT NULL AUTO_INCREMENT, 
        Music_id INT NOT NULL AUTO_INCREMENT, 
        PRIMARY KEY  (Student_id,Music_id)
    
    CREATE TABLE Friendships(
        student_A_id INT,
        student_B_id INT)
        PRIMARY KEY  (student_A_id,student_B_id)
    

    Handling the data views of the relationships can be shown using a Select statement. In the One-to-Many design finding a Student’s music uses the following query:

    Select Student.first_name,Student.last_name,Music.music_title 
    FROM Student 
    LEFT JOIN Music on (Student.ID=Music.music_student_id)
    

    Part of designing a database is figuring out what relationships you will need to query.

    Also look into normalizing databases.

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

Sidebar

Related Questions

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
Imagine I have a table like this: | A | B | C --------------
Imagine I have this simple table: Table Name: Table1 Columns: Col1 NUMBER (Primary Key)
Imagine you have this model: class Category(models.Model): node_id = models.IntegerField(primary_key = True) type_id =
Imagine I have a table with 3 columns: ID (unique ID) Description (varchar 2000)
Imagine I have a db table of Customers containing {id,username,firstname,lastname} If I want to
Imagine you have a User table with FirstName, MiddleName, LastName. For the sake of
Imagine we have an array of students: Students: Ben Sam ... Every student has
Imagine I have a service that looks like this: public interface MyAccountService { boolean
Imagine I have a table with two columns, a primary key and some data.

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.