Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ibskyde
Starting Member
4 Posts |
Posted - 2008-06-06 : 13:16:00
|
| I'm a total newb to SQL so I apologize if I butcher the description of what I'm looking to do :) Hopefully the example makes more sense. Is it possible for a single record in 1 table to contain relationships to several records in a different table?What I've got so far is 2 tables - Hardware and Software, with ID Specifying primary keys HardwareID and SoftwareID respectively. the hardware records are for computer details and the software obviously are for programs. What I need to be able to do is pull up a hardware record and be able to see what software is installed on it, and vice versa pull up a software record to see which computers it's installed on. The problem I'm running into is that a computer can have multiple programs installed on it and a program can be installed on multiple computers, so I don't know how to create that relationship to account for that. What I'd like to see is in the Hardware table a column for SoftwareID that has a foreign key relationship to the SoftwareID field in the Software Table, and vice versa....My question though is is that possible to do and have potentially multiple separate records it links to from that same column field? I might have a computer with say Windows XP Pro, Office 2003 Standard, Adobe Acrobat 8 and a proprietary rate calculator program that i need each to be displayed with their details when I open that computer's record. Or on the software side if I need to see which computers a license is already installed on then I want to make sure I can pull up the full list of computers.And finally if what I'd like to do isn't possible as I described it...any recommendations for a better way?Thanks all for the help! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-06 : 13:24:28
|
| Its possible. But i think a better approach will be to create a third table ComputerPrograms with Fields (HardwareID,SoftwareID) which will form its PK and they will link to IDs in Hardware and Software table. Each relation b/w Hardware and Software will represent a record in this table. |
 |
|
|
ibskyde
Starting Member
4 Posts |
Posted - 2008-06-06 : 13:45:21
|
| Makes sense - I'll play around with that a bit and see what I come up with. Thanks for the input!! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-06 : 13:51:58
|
quote: Originally posted by ibskyde Makes sense - I'll play around with that a bit and see what I come up with. Thanks for the input!!
You're welcome |
 |
|
|
|
|
|