https://supabase.com/ logo
Join Discord
Powered by
# help
  • p

    pedrodiaz

    11/18/2021, 3:21 PM
    Database relationships are associations between tables that are created using join statements to retrieve data. I don't know in the case of Supabase of the ORM handles the relationships without creating a foreign key, but anyways, you should create the relationships (Add the corresponding foreign keys to your tables)
  • r

    ryexley

    11/18/2021, 3:23 PM
    Thank you @User. I'm familiar with the concepts of foreign key relationships in relational database in general. My question was, more specifically, how is that done in supabase. I've not been able to find a way to define a true foreign key relationship between tables. I'm wondering if I'm missing it somewhere.
  • p

    pedrodiaz

    11/18/2021, 3:25 PM
    Maybe you should create them in the "SQL" section, click on "+ New query" them write the raw sql code
  • p

    pedrodiaz

    11/18/2021, 3:28 PM
    Copy code
    sql
    ALTER TABLE public.mytable
        ADD CONSTRAINT mytable_tabletorelate_fkey FOREIGN KEY (column_mytable)
        REFERENCES public.tabletorelate (column_torelate)
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        NOT VALID;
    that's how you create a foreign key
  • p

    pedrodiaz

    11/18/2021, 3:29 PM
    Copy code
    sql
    ALTER TABLE public.mytable DROP CONSTRAINT mytable_tabletorelate_fkey;
    And that way you delete the relationship
  • r

    ryexley

    11/18/2021, 3:31 PM
    Thank you for your help @User
  • c

    coozamano

    11/18/2021, 4:34 PM
    Does anyone have any suggestions for debugging high cpu usage? I'm constantly at 180%
  • r

    ryexley

    11/18/2021, 4:36 PM
    Either Task Manager or Activity Monitor (depending on your OS) should help you identify the process that's consuming CPU time. Should help you at least narrow it down.
  • c

    coozamano

    11/18/2021, 4:39 PM
    Is there a way to SSH into the supabase-hosted machine? Or should I just go ahead and self-host
  • r

    ryexley

    11/18/2021, 4:44 PM
    I don't know about that, but if it's not running on your local machine, then it's likely not anything related to supabase that's causing the high CPU usage is it?
  • c

    coozamano

    11/18/2021, 4:46 PM
    I'm referring to this (in the supabase dashboard) concerned that this will affect my launch today. Also a lot of queries end up taking a long time to run. Was wondering if theres a good way to debug
  • r

    ryexley

    11/18/2021, 4:47 PM
    Gotcha, that makes sense. I didn't realize that was what you were referring to. Thanks for clarifying. I'm unable to help with that though, sorry.
  • x

    xa

    11/18/2021, 5:07 PM
    hello, I'm wondering what's the difference between storage.objects and storage.bucket? It seems that only policies on storage.objects takes effect
  • s

    Steve

    11/18/2021, 5:22 PM
    order with foreign table
  • p

    prism0x

    11/18/2021, 5:23 PM
    Hi all, I looked around a lot, but couldn't find how to join tables
  • p

    prism0x

    11/18/2021, 5:24 PM
    I am able to create a query snippet on the website. Am I supposed to use that somehow?
  • x

    xa

    11/18/2021, 5:42 PM
    https://supabase.io/docs/reference/javascript/select#query-foreign-tables
  • x

    xa

    11/18/2021, 5:42 PM
    Is this what you're talking about?
  • p

    prism0x

    11/18/2021, 5:48 PM
    not exactly
  • p

    prism0x

    11/18/2021, 5:48 PM
    SELECT * FROM twitter INNER JOIN badge_wearers ON twitter.user_id = badge_wearers.user_id;
    SQL query I'm trying to run. It runs on the website, so there must be a way to do it with the library
  • p

    prism0x

    11/18/2021, 6:26 PM
    Is there a way to execute raw SQL queries?
  • v

    Vinzent

    11/18/2021, 6:34 PM
    No it's not possible to run raw SQL queries from the client. Instead you can write rpc functions https://supabase.io/docs/guides/database/functions
  • p

    prism0x

    11/18/2021, 6:56 PM
    How should I do this?
  • v

    Vinzent

    11/18/2021, 6:58 PM
    https://postgrest.org/en/v8.0/api.html?highlight=join#embedding-through-join-tables
  • p

    prism0x

    11/18/2021, 6:59 PM
    Sorry, can you elaborate a bit?
  • v

    Vinzent

    11/18/2021, 7:09 PM
    I think it's
    *,badge_wearers(*)
    as
    select
    parameter. Your
    on
    columns need a FOREIGN KEY constraint for this
  • s

    silentworks

    11/18/2021, 7:14 PM
    I've answered this in a thread https://discord.com/channels/839993398554656828/839993398554656831/910761522698010634
  • x

    xa

    11/18/2021, 7:27 PM
    Is it supposed to be something like
    *, badge_wearers(user_id)
    ?
  • v

    Vinzent

    11/18/2021, 7:28 PM
    I did indeed a mistake. (corrected now) your version would only return the
    user_id
    column from
    badge_wearers
  • x

    xa

    11/18/2021, 7:29 PM
    Oh ok
1...135136137...316Latest