CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Look for solution..

Print topic Send  topic

Author Message
pathans

Posts: 46
Posted: 10/12/2012, 11:53 AM

how can i attach one record in a table to multiple records in a table.

i have
systems table with primary key system_id
runbook table with a column for system_id

so when i am looking at a system i can show a runbook attached to that system.

what if i want to show that same runbook under multiple systems. how can i achieve that?

please let me know if you have any questions and i can try to explain my issue and share more detail.
View profile  Send private message
MichaelMcDonald

Posts: 640
Posted: 10/12/2012, 12:01 PM




Create a grid to display the table results and use the visual query builder to create a join between the id's in the 2 tables. Left join is a good option.

Create a third table and join it to the second table and watch what happens to the grid. Then, in the visual query builder play with the group by setting. That should really get things started.

Also, how are you creating the one-to-many relationship?


_________________
Central Coast, NSW, Australia.

View profile  Send private message
pathans

Posts: 46
Posted: 10/12/2012, 2:02 PM

here is the thing i am not sure how to do one to many relationship and looking for some ideas or help.
I can create the page/gird i am trying to figure out the logic.
here is an example i hope it help you understand.

systems table have 3 systems lets call it PC-123 and PC-456 and PC-789
runbook table have 4 runbooks ABC and D records.

now i can create another table and keep track of PC and their run book attachment and show them in a grid/search. but that way i have to create records for each system so if i am attaching 3 runbook this table will have 3 records for that one asset.


I am looking for a way that i go to record for PC123 and assign 3 (AB and D) runbooks and go to record for PC456 and attach (BD and C).
View profile  Send private message
MichaelMcDonald

Posts: 640
Posted: 10/13/2012, 2:11 PM

Have you done the task manager exercise in the codecharge examples?

The store application that ships with CCS also has a good example of one-to-many using products, and shows how to copy an array using a parent_id and many child_id's to create one-to-may relationship.
_________________
Central Coast, NSW, Australia.

View profile  Send private message
pathans

Posts: 46
Posted: 10/13/2012, 2:35 PM

I am trying to avoid using 3rd table because I am going to implement this multiple times.
I guess there are no other options thanks :)
View profile  Send private message
Waspman

Posts: 948
Posted: 10/15/2012, 6:17 AM

I've done "one to many" lots of times. It's fiddly and can be confusing especially the way it's done in the tutorial.

I don't like the way it uses the last record as most of my apps have multiple users.

I haven't come across another way, but it does get easier.

:)
_________________
http://www.waspmedia.co.uk
View profile  Send private message
bannedone


Posts: 273
Posted: 10/15/2012, 10:17 AM

FYI..

Using last record is probably not a issue even in multi user environments.

I have explored this and tested it as well. (only in MySql. But I suspect other SQL servers behave the same)

The php command mysql_insert_id() returns the last record inserted for that session, making it a reliable way to get the last inserted record from the autoincremented id field in the table.

I have seen code where the programmer gets the MAX value for the table id field. This method is NOT so pretty good as in a multi user environment there is no guarantee that the MAX function will get the record # you inserted.

Have fun
8-)
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2
View profile  Send private message
Waspman

Posts: 948
Posted: 10/15/2012, 2:11 PM

Yeah I remember that John.

Think it was MamboBrown that illustrated that was the case.

Still, I prefer to use an ID I create at the time of insert then I'm sure no other records are overwritten.
_________________
http://www.waspmedia.co.uk
View profile  Send private message
MichaelMcDonald

Posts: 640
Posted: 10/15/2012, 4:05 PM

pathans check your PM
_________________
Central Coast, NSW, Australia.

View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.