Alex
Alex

Reputation: 3079

Does Doctrine 2 required foreign keys to be defined?

I have a relational database, however, there aren't any foreign keys defined, and many of the tables are not InnoDB, so can't support foreign keys anyway.

I would like to start experimenting with Doctrine on this database, but there is a lot of reference to foreign keys in the documentation, so I'm not sure if this is possible.

I'm anxious about diving in and changing table storage engines to InnoDB and defining tons of foreign keys, because I don't want to impact performance if I don't have to.

Upvotes: 1

Views: 998

Answers (2)

moteutsch
moteutsch

Reputation: 3831

There is no reason for you to switch to InnoDB for Doctrine.

  1. No.
  2. I find the Doctrine's CLI tools for updating and generating the database schema will often try to generate the SQL with foreign keys. You can manually set up the database, or modify the code it generates, to avoid this.

So, no, it is not a problem.

Upvotes: 2

Sina Miandashti
Sina Miandashti

Reputation: 2087

If you define some Associations mapping for your entities it may convert to foreign keys by doctrine automatically

http://docs.doctrine-project.org/en/latest/reference/association-mapping.html

i you want those foreign keys in your db too you have to use doctrine CLI for creating your schema

for more info about using doctrine cli : http://docs.doctrine-project.org/en/latest/reference/tools.html

Upvotes: 0

Related Questions