Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi,

I have 2 tables where, table 1 has got projectID(Primary Key), Project Name etc..
table 2has got ProjectID, BusinesscaseID, etc but there is no primary key in this table.

I have to Filter all the Business case ID's which are related to the Project ID on the Table1 (This is called active project), now take out all active project's business cases and find out the other project id's which are related to these business cases.

BC (BCID, BCNAME, PROJECTID)- no primary key
AP (ProjectID,ProjectName) - Project ID is primary key

1 project has got many business cases and 1 Business case has got many project (Many to many relationship)

Can anyone help me with this please?

Thank you

What I have tried:

I tried using MS ACCESS but not having the results I wanted.
Posted
Updated 5-Feb-17 4:55am
Comments
[no name] 4-Feb-17 14:58pm    
First: Many to many and two tables do not match!
Second: A table without a Primary Sound like a bad design.

A building must have a good foundation, else it risks collapse. In software development, I liken the database component to the foundation of a building.
You must design the database correctly, else you will face many difficulties, such as this one, in subsequent development.
Firstly, to establish many-to-many relationship between 2 tables, you need a third table to broker it. For example,
table1                      table3                       table2
projectID(primary key)+---< projectID(primary key)      bizcaseName
projectName                 bizcaseID(primary key) >---+bizcaseID (primary key)
otherfields                                             otherfields
Secondly, every table must have a primary key, for table3, the 2 fields are the composite primary key.
Learn more:
1. Introduction to database design[^]
2. 1NF, 2NF, 3NF and BCNF in Database Normalization | DBMS Tutorial | Studytonight[^]
Do not move forward until you fix your database design.
 
Share this answer
 
v4
Comments
[no name] 5-Feb-17 11:37am    
Straightforward to the point introduction. A 5.
See the below article on joins for sql server

T-SQL Join Types | T-SQL content from SQL Server Pro[^]

This description the code to use when joining tables and the various relationship models
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900