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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:12:24+00:00 2026-06-12T20:12:24+00:00

I need to make an interface in which you can select each hardware /

  • 0

I need to make an interface in which you can select each hardware / materiel part of many electronic devices :

In a table i’m storing all the devices :

 :Name:     :Id:
Computer     1
Laptop       2
Smartphone   3
...         ...

I need to be able to associate different kind of materiel with them, by materiel i mean this table in which different items are stored :

 :Name:         :Id:
Keyboard         1
Screen           2
Mouse            3
Motherboard      4
Webcam           5
...             ...

my problem is, for instance, that i need to associate the item Keyboard with both computer AND laptop …

I already succeeded to associate items one by one, but because some devices got many items in common (like the keyboard) i need to be able to associate one item to all the devices i want.

So my question is simple: How can i store which item is associated with which device in a MySql database ?

Any hint there ?

EDIT :

Okay guys, so it seems that the Many-to-Many relation is the best way to do this, But anybody got some hint on how i should use sql queries to use the third table ? so i need to store for instance

:id1:        :id2:
  1            2
  1            3
  2            4
  3            1

But is there simple sql commands to do such things or do i need to use heavy php scripting in order to do this ?

  • 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-12T20:12:25+00:00Added an answer on June 12, 2026 at 8:12 pm

    If I understand, it’s a many to many relation.

    So you need a another table for this relation. This table is called a junction table

    This table would look like

    DeviceID   |     MaterialID
    

    And the primary key will be both columns.

    So for the same Device, you can have many material and for the same material you can have many devices

    Here’s a good article about it

    To insert your data. It’s gonna be 3 basic insert into.

    You need to insert in the device and material table first. Then you do the other insert in the junction table, cause you will have foreign key constraints on both field.

    To select all devices with a keyboard you would do something like this

    SELECT device.name FROM device INNER JOIN junctionTableName on device.id = junctionTableName.deviceId WHERE junctionTableName.materialId = yourkeyboardid
    

    You need a JOIN between the 2 tables. Here’s an example where you know the keyboardID but if you don’t know it, you would have to do a subquery or a query before to select the id where name = keyboard.

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

Sidebar

Related Questions

I need to make the top header of a report disappear. The part that
I need to make application with GUI interface and I want to take a
I need to make form which will be used to rank the students in
How can I make my dynamic proxy throw checked exceptions? I need a transparent
I need make some action (dump statistical data) before the Dart program ends. The
I need make all of my posts update. I use bulk upload for store,
Need to make certain Ruby strings in my program to be immutable. What is
I need to make a administrative GUI with lots of functionality like lists, forms,
I need to make a moderate system like the one in fmylife.com. Basically the
I need to make a point in time branch, when we release a new

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.