Type of relationship between tables (Laravel)

Asked

Viewed 128 times

2

I’m implementing my TCC, about photos and such.. But now I got a question when creating the tables... I’m using Laravel ok?

Next, I have the following tables:

users - roles - photos - tags

works as follows: There are functions of: 1) Fotografo 2) Client(who would be the photographer’s client)

That is, a photographer will have several clients.

In table photos, I had thought of the columns:

|  photos       |
| id            |
| path          |
| imageable_id  |
| imageable_type|

The imageable_type because for example, the photographer will have his profile image, the client also, the photographer may have company image, and when there was a photo essay, there will be several photos linking the photographer to the client. But in this case would be missing a column to link the photographer with the client?

For the tags

| tags           |
| id             |
| description    |
| taggable_id    |
| taggable_type  |

This one I think is easier because the type, will either be a tag for the photo or will be a tag for an essay, that’s all...

But in relation to photos even, what kind of relationship is it? Polimorphic Manytomany??

I hope you explained it successfully, thank you!

1 answer

0

I see some relationships...

Following the business idea (correct me if you need to adapt):

**Users** (contém Cliente e Fotográfo)
id
nome
cpf 
login
senha
ft_perfil
> outros dados, se necessário

*Login and password, you can put in a separate table for a control of when the person misses password or want to exchange and maintain a history to not allow identical passwords. Would be:

**acesso**
id_user (fk da Users)
login
senha
nr_tentativas (definir limite de tentativas quando a pessoa errar)
status (bloqueado, ativo, inativo)

As a photographer has n clients:

**r_fotografo_cliente**
id_fotografo (fk da users)
id_cliente (fk da users)
dt_associacao (data em que o fotografo foi associado a este cliente)
(ambos FK da user)

Like this combination of formed, there are photos...

**fotos**
id_fotografo (FK da r_fotografo_cliente para não perder a integridade!)
id cliente (FK da r_fotografo_cliente para não perder a integridade!)
path          
imageable_id
imageable_type

Browser other questions tagged

You are not signed in. Login or sign up in order to post.