One to many with Select_Single

PeterTeuben

New member
I'm creating a database for events and have a Table containing Dates and the Event_ID (one to many relation).
Because an event can have many dates.

I want the customer to choose the date and the Event name with the Fieldtype: select_single
But I can't get the date and Event name together in the select_singel.
The single_select shows the Date and the Event_ID:
15-02-2017 - 3

But what I want them to see is the Date and the name of the Event with select_single:
15-02-2017 - Concert Mozart

Is this possible?

Here is the information from the tables I use and the Dadabik information:

Tabel: Event_Dates
ID (int)
Date (date)
Event_ID (int) (foreign key to tabel Event ID)

Tabel: Event
ID (int)
Name (varchar)

Dadabik information Event Dates:
Fieldtype: select_single
Primary key: ID
Primary key table: Event_Dates
Linked fields: Date~Event_ID

Example:
Event_Dates
ID: 1 Date: 15-02-2017 Event_ID: 3
ID: 2 Date: 05-05-2017 Event_ID: 3
ID: 3 Date: 16-08-2017 Event_ID: 3

Event
ID: 3 Name: Concert Mozart
 

PeterTeuben

New member
Additional information:

What I mean is that a customer can select a Date+Evenent Name from a select_single in a order-form.

Customer Form

Enter your name: John Beethoven
Select the date and event you want to visit: 15-02-2017 - Concert Mozart
How many tickets: 4
 

eugenio

Administrator
Staff member
Hello,
I think you are using a select_filed in a table defining as primary key table the table itself, which is not correct.
A select_single (or lookup) is just a field that takes values from another table, if this table is, for example, "Event", you can have displayed the ID and the name of the event, not the date, because the date is in another table.

I see that you have a third table, orders, that you didn't mention; if the field is actually in "orders" (as I guess), it's impossible to have both name and date in the same listbox because they belongs to two different tables. You could create a view that contains all the information you need and use that view as "primary key table" for your select_single.

Best,
 
Top