I've a problem with my ER-Diagram, I hope somebody can help. The scenario: users can create contacts. The user can also add notes to the contact. The note consists of one text field. The contacts can be connected to the notes, that means; one contact can be linked to several notes and one note can be linked to several contacts. Now I have an entity "User" and an entity "Contact", it's a many to many relationship. But I'm stucked at one point: I'm not sure if "Note" also have to be an entity, because I've to show the many to many relationship between the notes and contacts, but I've also to show the relation between the user and the note. This would lead to a circle which is redundant. Any help would be appreciated thanks!
You definitely need to show note as an entity. Now, since you already defined a relationship between contact and note there is no need to show another relationship between person and note. You can get note for a user with user and contact combination.
Related
Good day Everyone,
I am using Workato and I want to create a recipe that will add multiple person to a specific contact in Xero. At the moment, I've tried to use foreach loop in workato and inside in it, I add a person to a specific contact. But it seems like during the creation of new person, it will only override the existing person in xero therefore only one person will be saved. Does someone know how to fix this problem? Please help.
You could use Add person(s) to contact action to add multiple persons to a contact.
First to say is I did research, this question has already been asked on SCN, but has no answer there. I also tried to google, but after an hour I surrenderd.
I have two entities, Userand Project. There are two association between them: One is 1:n saying who the owner of the Project is. But there is a second one, the one saying who(which User) candidates for which Project.
What I also can do is creating the entity in between, called Candidation. I allready definded the associations CandidationToUser and CandidationToProject.
Now can I define such a many to many relation directly without the Candidation in between? And after that, how can I implement it? I want to have a UserSet on the Project and a ProjectSet on the User. With the Candidation in between I only have a CandidationSet on both User and Project
In sylius, one order has many shipments. I find this strangule. In real life aren't they One-to-One relationship ? Thank you for your explication.
Currently there is only one. But in the future, there will be many. You can for example have multiple devilery addresses, or admin stuff decide to send some of ordered items via different shipping method under same order.
So, this many-to-one gives you flexibility and is investment into the future. Same with payments.
I have database contains those tables:
user, post, like and comment.
I was able to make diagram to show relationship between them.
one user has many posts, many likes and many comments.
one post or comment has many likes.
post can have comment also.
see diagram :
my question is how can i make friendship for user, (user has many friends)
please give me a diagram or strategy to do it, thanks.
Table
FRIENDS
---
SOURCE_USER_ID FK to USER
DEST_USER_ID FK to USER
We are building a webapplication which uses a database. Also we use an object relational mapper to access the database. One aspect of authorization in the webapplication is that the user may access an object referred to by an URL. The URL contains a unique id (for example the Primary Key) to a specific record in the database. Consider the following example.
a user may belong to many groups and a group may have many users (many-to-many).
a survey belongs to a group (many-to-one).
a survey may have multiple questions. (many-to-one).
Say we have the following URL: http://app.local/question/edit/10. This means we want to edit question with PK 10. Now, we want to verify if the logged in user may access question with PK 10. This can be done by retrieving this question, then it's survey then it's group and then all its users. If any of the users is the same as the logged in user the logged in user may access the question.
To generalize this a bit; we want to check if a record is reachable from another record by the known many-to-one or many-to-many relations. So if there is a many-to-one relation (like with a survey and a question then we should check if a user is reachable from the question through the survey and then through the group. The group has a many-to-many relation with the user so we should check if any (not all) of the users is the same as the logged in user.
If a table has multiple many-to-one relations, say; we can attach a CSS template to a survey and this template also belongs to a group then we have to check if a user is reachable from all many-to-one relations (thus the group and the template). The same holds of course for multiple many-to-many relations.
Are there Object Relation Mappers which support this behaviour? And what is this behaviour called, maybe reachability? Does Propel (for PHP) support this behaviour? I think this reachability can be done in any of the following two ways:
Execute a query to get each "parent", uses many queries)
Join all necessary tables to see if a record exists (the reachable users matches the logged in user) in one query.
Furthermore this behaviour of the ORM should support nested sets, thus if a group contains nested set behaviour it should also try to reach a user through the group's parent.
I don't think this kind of behaviour should be restricted to authorization; objects should simply be able to see if they can reach another object.
Note that I do not mean persistence by reachability: http://jpaobjects.sourceforge.net/m2-site/main/documentation/docbkx/html/user-guide/ch08s03.html.
Or... am I simply looking at this authorization wrong and is there a far better and different approach with an ORM?
I've handled this in the past using nested resources in Ruby on Rails (which uses the Active Record ORM). Rather than http://app.local/question/10/edit, the URI would be http://app.local/survey/5/questions/10/edit
In the controller you load both the question and survey. You check authorization by comparing the survey to the authenticated user's group memberships. One way to engineer this would be to embed this logic into the User class. For example, in the controller you have question and survey (and the relationship between the two is well understood by the ORM, i.e. question.survey). You could then check access as user.hasAccess?(question), which would be a relatively easy method to write. Pseudocode:
class User < ActiveRecord::Base
def hasAccess?(question)
return question.group.users.include?(self)
Yes, this will result in several queries behind the scenes, but ORMs do the work. I do it this way because you're left with solid schema and easy to read code. Don't optimize until you actually have a performance problem.