473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

master - detail

Hello everyone,

I'm new on this list and have been working for quite a while on a PHP app
that will make an HTML frontend for a PostgreSQL dbms. Works fine so far
but I'm having a little trouble with master - detail screens. My db
(roughly) has a hierarchical structure, something like

BAND -> RECORD -> SONG

When I display the record, band should be displayed on top of the screen.
When song is displayed, band and record should be displayed. (the real app
has more than 3 layers, but the idea is the same).

At the moment I use something like storing current band, current record in
a serialized _SESSION variable. It works, but not very smoothly because
PHP (or actually HTTP) has no idea of history, descent (the current screen
doesn't know what the previous screen was).

So I'm struggling a bit with this. Are there any "standard" solutions for
this master - detail setup? I found a lot on macromedia, but I don't use
that, it's just Vim on Linux.

TIA for any pointers / help!
Jul 16 '05 #1
3 3967
Hi Joop,

I am not completely sure I understand your problem.
If I don't forget the rest. :-)

Joop wrote:
Hello everyone,

I'm new on this list and have been working for quite a while on a PHP app
that will make an HTML frontend for a PostgreSQL dbms. Works fine so far
but I'm having a little trouble with master - detail screens. My db
(roughly) has a hierarchical structure, something like

BAND -> RECORD -> SONG

When I display the record, band should be displayed on top of the screen.
When song is displayed, band and record should be displayed. (the real app
has more than 3 layers, but the idea is the same).

At the moment I use something like storing current band, current record in
a serialized _SESSION variable. It works, but not very smoothly because
PHP (or actually HTTP) has no idea of history, descent (the current screen
doesn't know what the previous screen was).

So I'm struggling a bit with this. Are there any "standard" solutions for
this master - detail setup? I found a lot on macromedia, but I don't use
that, it's just Vim on Linux.
Nothing 'standard' about it. Just normal relations in your database, so just
'good programming practice'.

Let me explain:
You have a certain depth in your structure, right?
And I guess you have certain PHP-scripts that display information on a band,
or a record, song, etc. Right?

In that case I do not see the problem retrieving the information in the
hierarchy.

Let's take your example: BAND -> RECORD -> SONG

Supose you call a page showSongDetails.php?songid=456

where the songid in your db is 456

If your database is set up in a comprehensive way, the table that stores
songid (lets call it tblsong), also stores a reference (foreign key) to
your recordtable (tblrecord).

Same goes for tblrecord to tblband.

In that way you can say for every song, of which band it is, simply by:
SELECT bandid, bandname, etc etc FROM tblband WHERE
(bandid=(SELECT bandid FROM tblsong WHERE songid=$songid));

in which $songid must of course be replaced by 456

Hope that helps.

Good luck,
Erwin

TIA for any pointers / help!


Jul 16 '05 #2
On Tue, 02 Sep 2003 14:16:27 +0200, Erwin Moller wrote:
Hi Joop,

I am not completely sure I understand your problem. If I don't forget
the rest. :-)
No, you understood it perfectly but I oversimplified the question, let me
try again.

<big snip>
In that way you can say for every song, of which band it is, simply by:
SELECT bandid, bandname, etc etc FROM tblband WHERE
(bandid=(SELECT bandid FROM tblsong WHERE songid=$songid));


I only used the band -> record -> song setup as an example and a bad one,
sorry. Here's a better one (almost the real situation).

I have these tables

customer (key customer-id)
employee (foreign keys customer-id and person-id)
person (key person-id)

the relations are:

customer >-<< employee >>-< person

so a customer can have 0 or more employees and a person can be 0 or more
employees (can have 0 or more jobs). There's more, an employee can call in
sick 0 ore more times and a doctor can store 0 or more medical records on
a person, but the core is cust / emp / person.

In my PHP app, there are two routes that lead to employee, via customer
and via person. When coming from customer the screen should have customer
+ employee fields, when coming from person it should have person +
employee fields. So my app has to determin where it's coming from, and
that information table is not in a table. That's why I use session
variables now, but the nature of HTTP (stateless) and browsers make this
difficult to handle.

Hope this is a bit more clear. Has anybody else done this kind of thing in
PHP? TIA!
Jul 16 '05 #3
Joop wrote:

Hi Joop,

(Ben jij nederlands? / Are you Dutch?)
I am. :-)
On Tue, 02 Sep 2003 14:16:27 +0200, Erwin Moller wrote:
Hi Joop,

I am not completely sure I understand your problem. If I don't forget
the rest. :-)
No, you understood it perfectly but I oversimplified the question, let me
try again.

<big snip>
In that way you can say for every song, of which band it is, simply by:
SELECT bandid, bandname, etc etc FROM tblband WHERE
(bandid=(SELECT bandid FROM tblsong WHERE songid=$songid));


I only used the band -> record -> song setup as an example and a bad one,
sorry. Here's a better one (almost the real situation).

I have these tables

customer (key customer-id)
employee (foreign keys customer-id and person-id)
person (key person-id)

the relations are:

customer >-<< employee >>-< person

so a customer can have 0 or more employees and a person can be 0 or more
employees (can have 0 or more jobs). There's more, an employee can call in
sick 0 ore more times and a doctor can store 0 or more medical records on
a person, but the core is cust / emp / person.


Okay, that is clear.

In my PHP app, there are two routes that lead to employee, via customer
and via person. When coming from customer the screen should have customer
+ employee fields, when coming from person it should have person +
employee fields. So my app has to determin where it's coming from, and
that information table is not in a table. That's why I use session
variables now, but the nature of HTTP (stateless) and browsers make this
difficult to handle.

You can handle this in 2 'main' ways.
But I guess you figured that out yourself already. :-)
Maybe it help you when somebody else comments on it.

Let me clarify:

1) Just create 2 PHP-pages.
One for the route from customer (cust_empl.php),
One for the route from person (pers_empl.php).

This has the big advantage that you logically devide the routes and have the
possibility to do extra graphics/information/etc depending on the route.
I can imagine that you have to create more info depending on the route in
the future. In this way things are implemented easier/cleaner than with
if/then/else constructs of course.

And if a big chunk of the data is the same: Just make an include of it
(empl_view_incl.php) and keep the (breadcrumps??) logic out of it and in
the separate files (=cust_empl.php and pers_empl.php).

2) Store the state in _SESSION as you described and use already.

The fact that HTTP-protocol is stateless is excactly WHY sessiondata is
invented in the first place.
You use probably the _SESSION-array already to store other information I
guess???

So nothing wrong with your current approach I think.
I would advise you to stick to it unless one of the reasons in 1) is
compelling enough to switch.
Hope this is a bit more clear. Has anybody else done this kind of thing in
PHP? TIA!


Hope this helps.
I am sure you can find literature for both approaches if you look for it.
I have done a lot of coding like this and have a very pragmatic approach:
Sit back, think it over, and pick whatever solution makes the most sense to
you.
Regards and good luck,
Erwin
Jul 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Marcel | last post by:
Hi, I'm new to VS and ASP.NET and have a question about master/detail datagrids. I have a master datagrid filled with data via a component that contains a SQL adapter. Now I would like to fill...
2
by: ruca | last post by:
Hi, I have a master and a detail datagrid. I put detail grid showing insise of a column of master grid. The problem is that it's not what I really want. What I really want would be that the...
2
by: Ken C | last post by:
I've setup a Master detail table from a typed dataset on 2 different data grid The first one I bind it with the Master data table name The second data set I bind it with the MasterDetail...
2
by: Coen | last post by:
Hello, I have a strange performance delay of about 2 sec's in moving to the next row. I use multiple forms with each master-detail table relations. The master-table displays it's table rows in...
1
by: Sam | last post by:
Attached I am sending 2 URL's from MSFT ASP.net Quick Start Tutorial Web Site. 1) Run it URL: http://www.asp.net/QuickStart/aspnet/samples/data/GridViewMasterDetai... 2) View Source URL:...
0
by: Sam | last post by:
Sorry to post the same post multiple times but the URL Addresses were not Correct in Earlier Posts. Here are the correct URL's: 1) Run It URL is here: ...
1
by: Gary200 | last post by:
Hello All, I bind two datagrids in a master-detail relationship successfully. What I want is to set allowNew and allowDelete disabled in both datagrid using dataview. The code like this: ...
7
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent...
0
by: Mike Wilson | last post by:
Dear group, I have an invoice entry form, which is a simple Master fields / Detail grid. The main summary information of the invoice are stored in one table in a dataset, which is bound using a...
2
by: John | last post by:
Hi I am trying to create a master/detail form. I have my master and details tables dragged onto the dataset. I have also dragged the fields from master table on the form which has created the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.