KsqlDB support multiple key? (Primary key and FOREIGN KEY)

365 views
Skip to first unread message

suneel meena

unread,
Feb 12, 2021, 8:23:47 AM2/12/21
to ksqldb-users
Hi,

I am having Company table with COMPANY_ID as primary key, there is Foods table which will have multiple Rows with ITEM_ID as primary key and COMPANY_ID as foreign key.

Ksql is not allow join in Foods. COMPANY_ID = Company.COMPANY_ID.

Foods:

Primary key is ITEM_ID and FOREIGN KEY is COMPANY_ID

Company:  Primary key is COMPANY_ID

Attached tables screen shot.

 How ksqldb support multiple key?

 The scope is to join the two table by company ID to have all the info in same table 

FOODS.PNG
Company.PNG

Matthias J. Sax

unread,
Feb 13, 2021, 12:10:49 AM2/13/21
to ksql-...@googlegroups.com
Atm, FK-joins are not supported, but we plan to close this gap soon:
https://github.com/confluentinc/ksql/issues/4424


-Matthias

On 2/12/21 5:23 AM, suneel meena wrote:
> Hi,
>
> I am having *Company* table with *COMPANY_ID *as primary key, there is
> *Foods* table which will have multiple Rows with *ITEM_ID *as primary
> key and *COMPANY_ID as *foreign key.
>
> Ksql is not allow join in *Foods. COMPANY_ID = Company.COMPANY_ID.***
>
> *Foods:*
>
> *Primary key is ITEM_ID and *FOREIGN KEY is***COMPANY_ID*
>
> *Company:  ****Primary key is COMPANY_ID*
>
> *Attached tables screen shot.*
>
> * *How *ksqldb support multiple key?***
>
>  The scope is to join the two table by company ID to have all the info
> in same table* *
>
> --
> You received this message because you are subscribed to the Google
> Groups "ksqldb-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ksql-users+...@googlegroups.com
> <mailto:ksql-users+...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/ksql-users/5477b6e3-708f-49a4-8ca2-f98391e32ba7n%40googlegroups.com
> <https://groups.google.com/d/msgid/ksql-users/5477b6e3-708f-49a4-8ca2-f98391e32ba7n%40googlegroups.com?utm_medium=email&utm_source=footer>.

suneel meena

unread,
Feb 16, 2021, 8:07:14 AM2/16/21
to ksqldb-users
Hi Team,

is there any way and work around so we can get same functionality like FK key in ksqldb?

Thanks,
Suneel

Matthias J. Sax

unread,
Feb 17, 2021, 1:02:01 PM2/17/21
to ksql-...@googlegroups.com
You could conceptually pre-aggregate the left-hand side table using the
join FK-attribute as grouping-key. This way you can do a PK-PK join.
Afterward you could use EXPLODE on the join result.

Or maybe try using a stream-table join instead?

-Matthias
> <https://groups.google.com/d/msgid/ksql-users/5477b6e3-708f-49a4-8ca2-f98391e32ba7n%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ksql-users/5477b6e3-708f-49a4-8ca2-f98391e32ba7n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "ksqldb-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ksql-users+...@googlegroups.com
> <mailto:ksql-users+...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/ksql-users/9f50c43d-9187-4c1d-953b-d91797e8d869n%40googlegroups.com
> <https://groups.google.com/d/msgid/ksql-users/9f50c43d-9187-4c1d-953b-d91797e8d869n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages