Mysql Many to Many relation Navicat Fail Constraint
Posted by: Gustavo Andrade Ferreira
Date: March 27, 2012 12:20PM

Im bulding a new Data Model Diagram for my project and im having troubles creating a Many to Many relation.

I´ve posted a screenshot of the diagram specificly on the part that need work.

Here is the screenshot: http://clip2net.com/s/1K1EH (Please, let me know if the image is no longer avaliable)

In the image you´ll notice 3 tables: produtoloja, produtopedido, pedido,

produtoloja -> Hold information of products

produtopedido -> Makes the relation between produtoloja and pedido

pedido -> Holds information about the order of the product


Tables information:


Table produtoloja:

Primary Keys:

- ProdutolojaId

Indexes:

- (ProdutoId, LojaId) ->NON-UNIQUE
- ProdutoLojaId -> UNIQUE


Table produtopedido

Primary Keys:

- (ProdutoLojaId,PedidoId)

Indexes:

- ProdutoLojaId -> NON-UNIQUE

Foreign Keys:

[Name]fk_produtopedido_pedido_1:
- [Fields] PedidoId
- [Reference Table] pedido
- [Reference Fields] PedidoId

[Name]fk_produtopedido_produtoloja_1:
- [Fields] ProdutoLojaId
- [Reference Table] produtoloja
- [Reference Fields] ProdutoLojaId


Table pedido

Primary Keys:

- PedidoId

Indexes:

- PedidoId -> UNIQUE
- LojaId -> NON-UNIQUE

As you can see in the screenshot, Navicat is accusing an invalid relation between these tables. So my question is, what am i doing wrong? Are my primary keys and indexes ok? What can i do to improve this?

Any help would be appreciated! Thanks in advance!

Options: ReplyQuote


Subject
Written By
Posted
Mysql Many to Many relation Navicat Fail Constraint
March 27, 2012 12:20PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.