Welcome, Guest
Username: Password: Remember me

TOPIC: Can anyone help me with relations

Can anyone help me with relations 07 Dec 2012 13:44 #5887

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
in passed post I asked this.. but I could get it... so now I added and DB image, in order to better understanding

here is what I need:

the Usuarios (table) need to have 1 to N Oficios (table), please with a example... couse I added a relational field but thats seems no to do what I need. PLEASE help.

The administrator has disabled public write access.

Re: Can anyone help me with relations 07 Dec 2012 13:59 #5888

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
I need a relation table but I don't know how to connect with usuarios and oficios

should be something like:
[usuarios] -----  [usuarios_oficios]  ------- [oficios]
                        id_usuario
                        id_oficios
Last Edit: 07 Dec 2012 13:59 by jcasanova.
The administrator has disabled public write access.

Re: Can anyone help me with relations 07 Dec 2012 14:47 #5889

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
here is the final DB



My question is.... is it possible to show that in jcook?

the relation between usuarios and oficios ?
The administrator has disabled public write access.

Re: Can anyone help me with relations 07 Dec 2012 15:28 #5890

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

If usarios are users and oficios are trades (occupations/trades) then presumably, you want every user to select a trade/occupation from oficios, right?

Do I have your structure right? If so you need the following:
usarios - id (auto created by cook), name, oficio (foreign key field - oficios.id) .... all of your other fields go here
oficios - id (auto created by cook), title .... all of your other fields go here

Now, in your form you need to drag your fields to the layout. When you drag the oficio field to the form, drag one of it's related (descriptive) fields like name for instance to display something more friendly and recognisable by clicking the + sign on the field element. This will create a combo select box of users where the option name is the field from oficios that you drag to the layout. Naturally, it's id is what is actually saved.

Repeat this for any grid & fly layouts you need.

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: Can anyone help me with relations 07 Dec 2012 15:36 #5891

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
Hi Audible,

Heres is the scenario,

lets keep usuarios = users , oficios = occupations , detalle_oficios = occupations_details

I need, every user can have N occupations, and when a user register in the component I should be
set 1 or n occupations and set the accupations details for every occupation.

example:

user: Jhon doe
occupation: teacher
occ. detail: graduated from ___________
degrees __________
spoken lenguajes __________
etc.....

Occupation: Musician
acc detail: instrument owner: [yes/no] (boolean)
graduated: [yes/no]
years of practice: ___
etc.

I need to figure it out how to the user can insert all that data... from the tables already made (img)
and every user can see/change his details....

did I explain myself right?


Thanks in advance.
The administrator has disabled public write access.

Re: Can anyone help me with relations 07 Dec 2012 15:50 #5893

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
OK, I think I get it.

I haven't got time to look at it right now but, search the forum. Here's a tip:
As far as I see, you need a to use join tables that store 2 foreign keys for a number of your tables... This will help you to normalise your data.

So, you got users, occupations. I think it would be a good idea for admin to be able to create the base occupations that the user selects so...

create another table user_occupations that has user_id (FK), occupation_id (FK) then any other fields like start date, end date, description etc...

Then to enter the data, you have 2 choices - 1, build a multi step form with redirects (search 'working with redirects' by user BTB300) or 2, using ajax (search for 'how to ajax')

As much as possible, break your data down into separate tables... This might make building more complex but performance will be greater and you'll have very low eredundancy.

Best of luck,

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: Can anyone help me with relations 07 Dec 2012 16:13 #5895

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
So, you got users, occupations. I think it would be a good idea for admin to be able to create the base occupations that the user selects so...

the ocupation some of the fields are pre defined from other tables... like city, religion, state, etc, but the user has to insert some specific data
create another table user_occupations that has user_id (FK), occupation_id (FK) then any other fields like start date, end date, description etc...

yeah, thats what I did if you see the database image I created an USUARIO_OFICIO (user_occupation) wich holds id_user, id_accupation, my concern is about how to create the front-end view in order that the user, fill his data (table user) and create the relation (occupation - user) and then fill the occupation_details table...

I'll check BTB300 posts, to see what happens...

Thanks for your advices!
The administrator has disabled public write access.

Re: Can anyone help me with relations 07 Dec 2012 16:38 #5896

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Sorry, I didn't have time to check out the image in detail so I didn't notice that - Sorry!

Sounds like you're on the right track. Here's one thing I'd strongly recommend though - creating a user/profile plugin to package with your component. Here you can capture the 'standard' data you're component will require for all users no matter what. Then, use you're component tables to store the 'special' stuff - the data that will depend completely on individual user needs.

The advantages of this are that you are not having to recreate a load of existing stuff to traverse your component tables for stuff you can get almost immediately from the user object (joomla standard).

Also, this allows you to hook directly into your component immediately the user logs in, out, signsup etc...

Multiple profile can easily be set to allow registration into different groups/user types specific to your component too!

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: Can anyone help me with relations 07 Dec 2012 16:42 #5897

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
creating a user/profile plugin to package with your component.
how do I do that??
The administrator has disabled public write access.

Re: Can anyone help me with relations 07 Dec 2012 16:42 #5898

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
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: Can anyone help me with relations 07 Dec 2012 16:45 #5899

  • jcasanova
  • jcasanova's Avatar
  • Offline
  • Senior Member
  • Posts: 40
  • Thank you received: 1
  • Karma: 1
audibleid wrote:
Yeah I found them!

on those I will find ho to ad the user/profile plugin you talked about?
The administrator has disabled public write access.

Re: Can anyone help me with relations 07 Dec 2012 17:06 #5900

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
no, profile plugin info here: j-cook.pro/forum/9-coding-inside-your-co...ptions-from-2-params

Profile plugin's in j2.5 are pretty straightforward... It comes with an example plugin in default installation called profile. More info here: docs.joomla.org/Creating_a_profile_plugin

Best wishes

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.
Time to create page: 0.181 seconds

Get Started