ERD - issue about entities - erd

Im making an ERD now for medicine care.
I have an issue with 2 entities:
Patient and caregiver.
The caregiver is a person that helps for the patient and can do features on the application for the patient.
For now I choose that the patient is a separate user from the caregiver.
If its like that,I need to do a seperate entities for the caregiver and for the patient. When I do this , there is an overload on the ERD because the 2 entities can do the same thing on the system so they have the same connections to other entities.
In addition , they have just one attribute that is different between them and this is the diagnosis of the patient.
What to do?

I would suggest looking into adding the caregiver as a sub class if all the rows are the same apart from one. But having them both as separate entities wouldnt be an overload on the database as long as you add primary/foreign keys correctly. Have you got a current ERD i can look at?

Related

How to data model endorsement for a service provided by a person, Graph Data modeling

Hi I am new to graph database modeling and have some doubts about expressing an endorsment for a service provided by a Person. The use case is the following. PersonA gives Endorsement to a Service provided by PersonB.
The key point is that If I am recipient of the endorsment, I would like to know who has endorsed me. I have come up with several scenarios on how I could potentialy do that, but because of my lack of experience I have doubts on what would be the best aproach.
Scenario 1.
Endorsment is expressed direcly as a relationship and the service falls as a property under the endorsment So it will look like:
PersonA-------ENDORSE{service}--->PersonB
Scenario 2
I model an entity named Service. The problem is that when I do the relationship "ENDORSE" to service I would loose information on who am I endorsing. So I would have to keep a property in the relationship on who am I endorsing. Then the PersonB would AQUIRE endorsment for the SERVICE but he would not know who has actualy givern the endorsment. So..... it will look like this:
PERSONA----ENDORSE{personB}--->Service------ENDORSMENT{personA}--->PERSONB
Does this make sense ?
Scenario 3:
I normalize the second relationship "ENDORSMENT" and exclude the personA as a property , but than I need to query all Person to find out who have they endorsed.
How would you model this kind of relationship ?
Two important principles for validating a data model for a graph database:
if an entity or fact can be used more than once, then it should be stored
as the node
if the relationship of two nodes requires to store node
identifiers, then this relationship must be transformed into a node
So #Raj pointed the right way, in which case the model might look like this:
I recommend you read this:
https://neo4j.com/graph-databases-book/
http://patterns.dataincubator.org/book/
The second approach looks good, you don't have to add these properties on relationships.
It's possible to get person A who endorsed person B for service S.
The only issue with this is there will be multiple nodes for any service S. If that's not acceptable.
You can replace the Service node in the second approach with Endorse node E and connect this E to service node S.
So there will be four types of nodes.
EDIT:
Adding an image for clarification.
Rename REL1 and REL2 as you wish.
#Stdob suggested some good names for these relationships.

Database relationship between employee and timesheet

I'm creating a system whereby it allows employees to log in day they work (eg, Monday/Tuesday...etc) and their time.
I have the "Employee" tables and a "Timesheet" table. Should the relationship be one to one or many to many or others?
Thanks for the help.

ERD Issue: Gallery & Company Relationship is wrong

Quick Summary: I'm building an ERD diagram and got lost in connecting two tables.
Introduction:
I'm building an ERD diagram for my project. Idea is pretty straight forward: I can type information about the company and it will be saved in the database. Later, I can see the list of submitted companies, as a list. As of now, I've information on the "paper", which I've implemented into my ERD diagram, so that later I can tell database, what exactly must be saved and where.
I have a primary table "Company_Info" which stores all the information about the company in the database. Using common sense (or not :)) I've created "Foreign Tables" that would store information about the company: "Gallery Images", "Opening_hours", etc. This way I believe, the database would more or less clear and readable by others.
ERD Diagram with the Description of all relationships
Problem Statement
The idea was to create a simple gallery for the company, so that they can upload their Product-pictures. If it's possible I would like to talk about the relationship between the Gallery and the Company tables. The way I see it, I think it should be like this:
One company can have 0,1,2 or many images. (Gallery_Images Table)
Images must be assigned to only 1 company. (Company_Info Table)
The relationship is one mandatory to many optional. (Many images & one company)
Question: I think the relationship between the Gallery_Table and Company_Info table will not work. Reason: Wrong relationship. I'm confused about the connection between those two tables.
I have made a connection via company PK & FK. This way, I think, the database would know what images belong to that specific company.
Confusion is with gallery_id in Gallery_Images table. Shouldn't it be connected with the company_info table too?
Image(BLOB) is a repeating group in Gallery_Images. This is not a problem if your purpose is to draw a diagram of an ER model.
If your purpose is to draw a diagram of a relational model, then the repeating group is a departure from First Normal Form. Relational schemas that depart from 1NF are generally subject to terrible problems, both with regard to performance and with regard to data management itself.
I don't see the Gallery table in your diagram. Did I miss something?

Code Organization - Relation or Repository

I'd like to have your opinion about code organization. I have two entities: City and Country. I have an unidirectional ManyToOne between them, Many side is of course City.
Now, I need to get all the cities corresponding to a country. I have two choices:
Changing the relation to a bidirectionnal ManyToOne
Creating custom method in City repository
What is the best way to do so ?
Depends. If the two entities are in the same Bundle (or in Bundles that require each other's presence), then make it bi-directional, especially if you think this'll be a common thing to search for.
On the other hand, if this is a special case, the entities are in different Bundles, and you don't want to couple them further, then it's better to make a custom method for it.
It depends on what kind of data and how oftend you need it:
if you have the Country object and you need City objects, make it a 2-way ManyToOne
if you have the Country id and you need City objects, add a query to repository
if you have the Country id and you need City ids, add a query to repository
#Erik's response is also a good view on the subject

ER diagram - design issues

There are 3 entities:
vehicle_model
vehicle
extra_options (such as open top, leather seats, etc..)
Vehicle model can have a subset of the extra options.
Vehicle can have a subset of it's model extras.
I've been trying hours to figure out how to represent this as er diagram, but without success. I Thought about ternary relationship ,and although I don't understand it completely I think this isn't the way.
I thought about creating another 2 entities, model_ext & vehicle_ext ,so that vehicle_ext would be connected to model_ext but this isn't a good design.
This is my first er diagram design. I'm really lost (read er-diagram chapter in "Silberschatz, Database System Concepts" three times already) so any idea would be appreciated.
did you try adding a new table say 'vehicle_vehicle_model_extra_options_map'? (you can name this table to any thing short, but for better explanation i use __map as a standard way for defining the map tables.)
note those two null able foreign key columns in this table.
Basically, vehicle has one to many relation to extra_options, and vehicle_model has one to many relation to extra_options table, therefore the new table was added.
updated:

Resources