Welcome, Guest
Username: Password: Remember me

TOPIC: How to use relational tables in j-cook?

How to use relational tables in j-cook? 05 Dec 2012 12:10 #5836

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
How to use relational tables in j-cook? is it possible?
The administrator has disabled public write access.

Re: How to use relational tables in j-cook? 05 Dec 2012 13:05 #5838

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

Relating tables is pretty straight-forward thanks to cook!

Lets say you have 2 tables - families and family_members each with an id (auto created in cook) and a name field + in the family_members table, add a foreign key field type called family. Then, from your tables list on the left-hand side, drag the families table into the dashed div and click the save button. That's it! Simple, eh?

Now all you have to do is create a layout to enter and view data for both tables. When you do this and you drag your fields to the layout, simply click the + sign on the foreign key field (family) and drag one of the related fields from that table to your layout. This is what you'll see in your layout - either in the combo dropdown on your form or in a grid/fly.

Hope it 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: How to use relational tables in j-cook? 05 Dec 2012 14:28 #5842

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
what you describe is a 1 to 1 relationship right?

because I need a 1 - n relationship
Last Edit: 05 Dec 2012 14:29 by jcasanova.
The administrator has disabled public write access.

Re: How to use relational tables in j-cook? 05 Dec 2012 14:31 #5844

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

No this is a 1 - many relationship. You could add multiple family members to a family in this example.

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: How to use relational tables in j-cook? 05 Dec 2012 14:40 #5845

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
so, if its 1 - n its not working =(

I added 2 families

then in family members added 2 names with the same family,

and this create 2 regs with the family but both with and unique Id....

The administrator has disabled public write access.

Re: How to use relational tables in j-cook? 05 Dec 2012 14:47 #5846

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Yes, but there is only one family id there - your foreign key. 1 family->many members = 1-n
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: How to use relational tables in j-cook? 05 Dec 2012 14:48 #5847

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
I should be able to open a family en see the family members
The administrator has disabled public write access.

Re: How to use relational tables in j-cook? 05 Dec 2012 14:51 #5848

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
You need to create a layout for that - 1 where you filter by family and show related members. What you are currently looking at is family members from all families.

You'd need separate query - prepareQuery() function in your model to get say family 1 and all of it's members.

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: How to use relational tables in j-cook? 05 Dec 2012 14:54 #5849

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
Ok, but that cant be done here in jcook right?

can you tell me the use of "default" in table it s like "primary key" ?
The administrator has disabled public write access.

Re: How to use relational tables in j-cook? 05 Dec 2012 14:58 #5850

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
there's a few things you can do:

1 - add a filter to the table based on your family
2 - group by family (find this in your grid properties of the layout
3 - as I said before, add a where clause in a new 'case' so you can switch to filter by family.id (after download)

Hope it 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.
The following user(s) said Thank You: admin

Re: How to use relational tables in j-cook? 05 Dec 2012 15:05 #5852

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
thanks I'll try, when Paid the account, in order to download (when I'll be satisficed that cook fill my needs)

I got a problem with the relation

I added the relation to the view... and added the field from the FK table, the field is an BOOLEAN
when I added to the layout it shows a dropdown empty.

What happens there?
The administrator has disabled public write access.

Re: How to use relational tables in j-cook? 05 Dec 2012 15:08 #5853

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
I can only add just 1 record from the fk table??????
The administrator has disabled public write access.

Re: How to use relational tables in j-cook? 06 Dec 2012 13:08 #5861

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Yes of course.

1:N is linking only one foreing element.

If you want to connect multiple, you need N:M.

N:M is possible manually in Cook. Then to show them you must code a little bit.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: How to use relational tables in j-cook? 06 Dec 2012 16:35 #5864

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
Admin, thanks, I just paid the 6 months! (not with this account) I'm very exited!
The administrator has disabled public write access.
Time to create page: 0.167 seconds

Get Started