Re: Ideas?? (OT- MySQL)

From: Date: Thu, 25 Jan 2001 22:12:44 +0000
Subject: Re: Ideas?? (OT- MySQL)
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-36711@lists.php.net to get a copy of this message
You will probably be much happier in the future if you make a one-to-many setup rather than a many-to-many. As Mathew said, create your tables with: BID table: bidid, projectid, OtherFields PROJECT table: projectid, OtherFields If you are at a project and want to look at bids, just "select * from bid where projectid ='<CurrentProjectID>'" Even if you have multiple projects per bid, you might try to create one bid record for each project in that bid which would maintain the above methodology. But having fields such as Bid1, Bid2, etc, is a VERY bad idea. At various client's sites, I've had to maintain/fix other programmer's programs who used that technique and it will strangle the program. Best regards, Randy Thursday, January 25, 2001, 1:17:37 AM, you wrote: MK> <Website4S@aol.com> wrote ... >> I am creating a web site which allows users to post projects and then >> others to place bids. I am setting up two tables in MySQL 'Projects' >> & 'Bids' my problem is how best to cross reference. What I was >> thinking of doing is creating a number of fields in the Projects table... >> >> and then inserting the BidID from the bids table into Bid1, and if >> that is already used then it will go into Bid2. But how many Bid# >> shall I create?? I`m sure there must be a faster method than this, >> anyone have any suggestions?? MK> This is a standard question where you have two tables that need to be linked MK> in a many-to-many relationship. The answer is that you need a third table, MK> called for example ProjectBids. It has two columns, one for Bid ID and one MK> for Project ID. Each row links one bid to one project. You can enter as many MK> rows as you like, so each bid can be linked to one or more projects, and MK> each project can be linked to one or more bids. MK> But are you sure you have a many-to-many relationship? It sounds like each MK> bid might be associated with just one project. In that case you could just MK> have a column in the Bid table that contains the Project ID.

« previous php.general (#36711) next »