Welcome, Guest
Username: Password: Remember me

TOPIC: m:n relation

m:n relation 07 Nov 2012 11:59 #5032

  • torbonaut
  • torbonaut's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
hi

I have a table/view documents (title + filename) and 3 other tables/views and I want each of the 3 other views to store their documents all in the documents table.

e.g.: I have a table/view "foo" where each row could have 0, 1 or more documents, same for another table/view "bar"

I guess I could let the user create the document first and then select it in the other view. But a) bad usability and b) I could only select 1 document.

So I want to add or chose 1 or more documents within a view. Any Ideas?

Kind regards,
Torben

PS: Is there a way to edit code fragments within cook? Or do I need to download it all the time and merge it again and again? Sorry for being a newbie.
The administrator has disabled public write access.

Re: m:n relation 07 Nov 2012 12:44 #5033

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi & welcome!

Firstly...
PS: Is there a way to edit code fragments within cook? Or do I need to download it all the time and merge it again and again? Sorry for being a newbie.
Yes, you will need to add custom code after download as you said then merge with any editions you make in the builder.
I guess I could let the user create the document first and then select it in the other view. But a) bad usability and b) I could only select 1 document.
Really speaking you would be better off taking this approach to maintain a normalised dataset. I mean, you don't want to have to have multiple fields for files in a table just to allow users to store multiple related files for a record, right?

I would create something like;
  1. files table - with id, title, file
  2. foo table - with whatever fields you like then use a join table like;
  3. foo_files where you store just 2 foreign keys - files.id + foo.id
This way, you can have as many (or no files) associated with a foo record as you like. Similarly, you could take this approach for any other tables you wish to link files to.

Then, to display the data (views and layouts), you will need to do some custom work such as
  1. using redirects to step-by-step through creation and re-use parameters AND/OR
  2. ajax and loading necessary forms/data according to options selected by the user
Much of the calling related data into a view/layout can be done inside COOK as you have access to drill-down and select fields from related tables when using foreign keys. Also, there are a number of posts on getting & displaying related info if you have a quick search around.

Hope this helps,

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: m:n relation 07 Nov 2012 13:10 #5034

  • torbonaut
  • torbonaut's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
Many thanks. I'll have a look into that.

Cheers
Torben
The administrator has disabled public write access.
Time to create page: 0.089 seconds

Get Started