Conversation

Dashes

  1. Toksyuryel toksyuryel

    Using PostgreSQL, can a foreign key reference the table it appears in? Or is there some other way to do this? !coderpony #

    about a year ago from web
    1. Bit Shift bitshift

      @toksyuryel Isn't a foreign key _by definition_ a reference to another table's primary key?

      about a year ago from web
      1. Toksyuryel toksyuryel

        @bitshift Essentially, but I was wondering if there was a way to do the same thing within the same table. The specific use case here is to guarantee that the replyto column of a post row actually matches the id column of an existing post row.

        about a year ago from web
        1. Toksyuryel toksyuryel

          @toksyuryel *posts row, in both instances

          about a year ago from web
        2. Bit Shift bitshift

          @toksyuryel Not too sure on whether PostgreSQL has such a feature, but maybe you can set that as a value constraint somehow?

          about a year ago from web
          1. Toksyuryel toksyuryel

            @bitshift Certainly could, though I'd rather not. Maybe I could just work around it by referencing the post id in the conversations table (which references the posts table. Circular references ftw?)

            about a year ago from web

Affiliates

BUCK Bronies UK Equestria Inspired EquestriaGaming Pony Mix Central PonySquare
Cornify
Browser Ponies
+ -