d.lanza38
d.lanza38

Reputation: 2617

Doctrine 2 and a de-normalized database

I'm looking into Doctrine 2 for a project I'll be working on and have some questions. The database I'll be working on is not normalized and I can't change that. This database doesn't even enforce referential integrity. Is Doctrine 2 a viable solution in this case? In addition I'm concerned if a change is made to the database, will the app break if I do not generate the doctrine database schema.

Upvotes: 0

Views: 130

Answers (1)

Stepashka
Stepashka

Reputation: 2698

On the project I worked on there was a need to have couple of denormalised tables in order to improve performance. I used doctrine for it and it worked ok. So answering your questions:

  • Yes, Doctrine can work with such database. There is nothing that limits it.
  • You can add subscribes that keeps your database integrity. For example you make a change in table Product. By doing it it is required to make a change of the price in StoreProduct table. So you create trackProductChangeSubscriber that detects changes in Product and do changes required in StoreProduct. Other option is if you need to change data in related table, you can easily use PersistentCollection in the entity to change related tables.
  • Not sure I understand what you mean. Schema is configured once and stays like it before you do the changes to the DB structure. You do not need to change schema when you change data in the tables.

I hope I've answered your question.

Upvotes: 1

Related Questions