Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

How to create tables with foreign keys correctly?

edited November 2015 in Development

Hello again!

As I said before, I'm creating an application (to create "Jams"), i'm trying to understand now the database structure file (creation scripts).
By now I have this for foreign keys:


    ->Column('UserID', 'int', FALSE, 'key')
    ->Column('GroupID', 'int', FALSE, 'key')
    ->Column('DateCreated', 'datetime', NULL)
    ->Column('DateUpdated', 'datetime', NULL)
    ->Column('IsPublic', 'tinyint(1)', '1')
    ->Set($Explicit, $Drop);

But I use also this when a FK is a PK member in another table:
->Column('GroupID', 'int', FALSE, array('primary', 'key'))

Although, in other applications I see they don't use "key" for FK's in some cases.

How's the better way to do it?

Thank you!

Off-topic: I ask under this category because I can't select "development", and I just upgraded to v2.2


Sign In or Register to comment.