Relationship in conceptual model (ER diagram) - mysql

I have a simple and probably. banal question. I am working on the first, conceptual phase of an entity-relationship diagram.
This DABMS will be used by some Managers, that will control (registrate and modify accounts) of customers.
In my diagram I have the two entities "MANAGER" and "CUSTOMER". Is it necessary to connect them with a relationship (M:N), to specify that the Managers are those who will manage the customers' account, or this relationship is unnecessary?

to specify that the Managers are those who will manage the customers
No. ER diagrams typically show relations that are reflected in your database.
Example, what would be visible in your ERD
Each customer has a manager assigned who's responsible for this customer => 1:n - each customer has one manager but one manager can be responsible for multible customers.

Related

Can 2 relationships have a relationship between them (Database)?

Consider the scenario between a Project, Task, and a User (ER diagram attached included):
A project can have multiple tasks and a task can be in multiple projects (thus the many-many relationship ProjectTask)
A project can have multiple users and a user can be in multiple projects (thus the many-many relationship ProjectUser)
Check the above example's ER Diagram here
Now a ProjectTask can be assigned to multiple ProjectUsers and a ProjectUser can be assigned multiple ProjectTasks, basically a TasksAssigned relationship
How will I go about storing that information in a database? Can two relationships have a relationship? If yes, is there a better way to showcase this scenario? And if no, how do you show this relationship?
You can have a three-way relationship, in your case:
user
project
task
You probably want to guarantee that the user and task have the same project. That can be handled by declaring composite foreign keys to the projectTasks and projectUsers tables. The structure guarantees that the user and task are in the same project (because it is explicitly mentioned in the row in this table).

MySQL modelling task

I have next task to do in MySQL:
We have Accounts, Farms, Customers, and Users
An account belongs to a Customer
A User has access to one or more accounts
A User has access to one or more farms tied to that account
A farm is tied to one account
Here is ER Model:
Can someone take a look and check whether I made this correct?
For this SQL modeling task, you have three types of entity relationships: one-to-one, one-to-many and many-to-many (How to implement one-to-one, one-to-many and many-to-many relationships while designing tables? for more detail on their implementation).
In your toy model, if "a User has access to one or more accounts," this is modeled as a one-to-many relationship between the user and the accounts, which requires a foreign id on the many side (i.e. every account has a user_id) but user does not have an account_id.
The account-customer relationship appears to be well-modeled, because it is one-to-one (so either table can hold the foreign key), but your one-to-many relations appear to have some errors.

ERD: manager and hotel, going from a one:many to a many:many relationship

Currently, a hotel is managed by a single manager only. A manager can manage 0 to many hotels, as shown in the below diagram (unfortunately I can't post pictures yet, however I have provided the links:
https://postimg.cc/nXJtL2n5
Now there is a change such that some hotels will be managed by multiple managers, and others will still be managed by a single manager. For example, a hotel used to have a single manager, now it has a bookings manager, a cleaning manager, and a maintenance manager. I want all of these manager roles to appear in the HOTEL entity.
The below image is what I have so far.
https://postimg.cc/mzDP5RqQ
Is there a way to link the hotel with the new manager roles?
Any help is appreciated.
Cheers.
You need to create a separate entity for each of the managers e.g booking, cleaning and maintenance manager as a seperate entity; and then depict the 1:M relationships with the manager and hotels that they are managing. As a PK you need to have a unique key for each of those entitys so you can show the FK in the table they are referencing.
You want to avoid having M:M relationship so they need to be broken down to achieve redundancy in your final database design.

Database ER Diagram of a Multi-tenant System

We are designing a multi-tenant system and we want to employ The shared database, Schema sharing, shared data table.
Since Our Tenants could be State (US States), County or Individual Organizations. The following figure depicts a high level view. (Where O1,O2.. are Organizations, and U1,U2.. are users)
A state can have many organizations under it.
An Organization will one or more User under it.
An Organization can have one or more Organizations (sub organization) under it.
A User from one organization cannot belong to other organization.
Every Tenant will have its own Admin who can perform CRUD on Organization/User (Ex Creating Organization and assigning User to Organizations)
A SuperAdmin (from our Company) will be able to activate/deactivate any Tenant.
Below is a high level ER diagram. Since tables are shared between tenants, we have a tenant_id column in all tables.
Since an organizations can be nested under an organization, I am thinking of having a self referencing table with Discriminator Column.
I am looking for inputs to optimize/correct this ER Diagram and before anyone starts yelling at the ER, I would like to mention that I am a programmer and not a DB expert :).

One to many relationship in ER diagram, MySQL Workbench

Hi I'm drawing an ER Diagram using MySQL Workbench for my final year project. It's about a shipping company, where buyer & shipping agent are involved in a shipping process with my client.
So far the buyer and agent have same attributes. So I decided to keep both of their data in a table and differentiate them using an attribute (type in my case).
As you see in my picture I couldn't able to make a N:M relationship between shipping table and external table. It always give me 1:M relationship. When I try to do the relationships manually it creates a another relational table and make a 1:M relation with it.
Can anyone assist me with my problem? Further how efficient to have a relational table in my case.