Do search relational database

Can I ask you for your help also? I am stuck in this problem:
Search for EVENTs: value should be a ANIMAL but right now it is a number.

I have a simple app with two databases.
One is ANIMAL
with Animal_ID (number)
and Animal_NAME (text)

second is EVENT
with Animal_ID from ANIMAL which is key
And Event_TYPE (text)

I want to select an animal and get all events that the animal has been through.

So I have input button A which is an element type integer.
Selecting an animal is simple: on key field Animal_ID i do a search:
Search for Animal (constraint Animal_ID = Input A value) first item
that returns my desired animal correctly

Then I build a repeating group where I want to see all occurred events.
I do a search also:
Search for Event (constraint Animal_ID = Input A value… and it does not accept my search and turns red
and he issue editor says: Search for EVENTs: value should be a ANIMAL but right now it is a number.

What am I doing wrong?
(Btw I dont want to use the ‘List’ option, just want to know how to get it right)

Why don’t you want to use the List option? That’s what bubble is designed to do.

How is the Animal_ID on Event set up in the database ?

From the error it sounds like it has a type of animal, rather than number.

Can you post a screen shot ?

So, as others have said, Bubble does not deal with Keys or Foreign Keys. You can set it up like that, but you need to do the join manually, and I can’t really think of any advantages.

If you have set up Event like the second field here … (Animal_Id_Linked)

image

So with Type “Animal” - then that field is not a Foreign Key in the normal sense of the word. It does not hold the unique ID of the Animal record.

It holds the ENTIRE Animal record that you have attached there, so a little bit like an Object Database, or embedding in mySQL.

So when you do the RG event search …

The top one gets the same error as you are seeing.

image

To do that search, you need to do a Search for Animals with the same Id, and then take the FirstItem (again, no keys here, so your Animal_Id is not unqiue as far as Bubble is concerned).

Or … you can do the middle one, and set Animal Id to be a Number, and then search for it.

An easier way, if Animal_Id is set to Animal, would be have your input as a Search Box, which pulls back Animal records. That way the value of the search box would in fact be an Animal.

Hope that makes sense !

Oh, and it will be far far easier to use a List on Animal of Events. I promise you.

Hi @NigelG,

Thanks for your reply!
I tried to use the List option but it does not create the output what I need.
I will give you my list it generated:

17

Wat I need is one event per row, not a sum up of all events that occurred with the specific animal on the same row.
How can I do that with the List option?

Kind regards,

Cornelius.

You need to put the “list” on the Repeating group source, then it will come out as one per line.

Hi @NigelG,

These are my database structures:

28

40

I did what you suggested me but thuis is the only outcome:

Please advise…

Kind regards,

Cornelius.

I think you want a List of EVENTS on a specific Animal, right? The way that’s set up makes it look like you have a bunch of different animals for every Event.

Hi @andrewgassen,
Thanks for your reply.
Yes, you are correct:
I want a list of events for one animal at a time…

How do I do this…

Put the list of Events on the Animal.

Hi @NigelG & @andrewgassen,

I altered my databases according to the 1 animal : N events.
When I do Ia search for the animal it is working ok. I get the animal of my choice.
But when I do a search on the events in my repeating group my problem stays the same.
These are my databases:
25

38

These are my data inside the records:

54

57

I have an input box (Input Animal_ID) and a group which refers to the Animal database that shows name and animal type. I do a search on database ANIMAL:

Do search on ANIMAL’s first item (constraint: Animal_ID = Input Animal_ID value)
That works fine: I get my desired Animal ID and the corresponding fields ar shown.

Now I want to display all events for the animal in a repeating group:

Do search on EVENT’s (constraint: Animal_ID=Input Animal_ID value … it asks me for more.
How do I produce my list with one event per row?

Thanks again for helping me and looking into this,

Kind regards,

Cornelius.

Why wouldn’t you just use “Current Animal’s Events” instead of the Search for Events?

Hi @andrewgassen
Please explain how do I do that and where…
I can only display the field Animal_ID that way. Event_ID, Event_Date and Event_Type I cannot reach.

03

I think the issue is you’re saving ID’s instead of the actual Event. Is there a reason you’re saving a list of Event ID’s on the Animal instead of a list of Events? This is not a setup I’ve ever seen used before, so I’m curious why the default Bubble behavior wasn’t sufficient for your use case.

This topic was automatically closed after 70 days. New replies are no longer allowed.