Jump to content

Archived

This topic is now archived and is closed to further replies.

chihcc

Help( many -many relationship)?

Recommended Posts

Hi, anyone can tell me how to solve the many -many relationship(database) problem using DW without using the extention from DW?

or can suggest any simple method on solving this problem ?

thanks u!!

Share this post


Link to post
Share on other sites
Hi, anyone can tell me how to solve the many -many relationship(database) problem using DW without using the extention from DW?

or can suggest any simple method on solving this problem ?

thanks u!!

248426[/snapback]

 

hi

 

can you give us a better idea of exactly what youre trying to do (ie what databases/tables) youre working with and i may be able to help

 

cheers

 

mark

Share this post


Link to post
Share on other sites
Hi, anyone can tell me how to solve the many -many relationship(database) problem using DW without using the extention from DW?

or can suggest any simple method on solving this problem ?

thanks u!!

248426[/snapback]

 

first off, welcome to the forums!

 

easiest way is to create a "joining" table. basically, just a table that holds the ids of the related items, so, if i have a class->student many-many relationship, i would have a classes table, a students table, and a roll table. the roll table would only store two pieces of data: class_id and student_id. that way, i can easily see either all the classes a student is in or all the students in a particular class.

Share this post


Link to post
Share on other sites
Hi, anyone can tell me how to solve the many -many relationship(database) problem using DW without using the extention from DW?

or can suggest any simple method on solving this problem ?

thanks u!!

248426[/snapback]

Hi, anyone can tell me how to solve the many -many relationship(database) problem using DW without using the extention from DW?

or can suggest any simple method on solving this problem ?

thanks u!!

248426[/snapback]

 

Supposing that you are having two entities:

Users: (UserId, UserName, UserPassword)

Products: (ProductId, ProductDescription)

 

Supposing that an user have more than one sales. You can store this information within an intermediate table:

UsersSales with the following structure (UserId, ProductId)

 

Your SQL will sound smth like that

SELECT * FROM users 
[INNER|LEFT|RIGHT] JOIN UsersSales
ON Users.UserId = UsersSales.UserId
[INNER|LEFT|RIGHT] JOIN Products 
ON UserSales.ProductId = Products.ProductId
WHERE UserId = x

 

You haven't been so specific about what are you going to do.

 

For more details about SQL JOIN you should visit: W3Schools website

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.