Solved

Entity Relationship Diagram help.

Posted on 2012-03-26
6
528 Views
Last Modified: 2012-03-29
Hi,  Very rusty on Entity Relationship Diagrams,  maybe 7 or 8 years since i last done one.  Could somebody look at my diagram and see if everything looks ok, or highlight any errors for me. Thanks.

Entity Relationship Diagram
0
Comment
Question by:jonathan1978
  • 3
  • 2
6 Comments
 
LVL 24

Expert Comment

by:johanntagle
ID: 37769500
Without seeing your use cases, I guess the best way to validate it is to describe the relationships in words and see if they are what you intended them to be:

A user can have one or more user_types and a user_type can have one or more users.
A photo can have one or more users.  A user can have only one photo.
A photo can have one or more comments.  An activity belongs to at most one photo.
A photo can have one or more activities.  A comment belongs to at most one photo.
A category can have one or more comments.  A comment belongs to at most one category.
An activity can have one or more comments.  A comment belongs to at most one activity.
An activity can have one or more alerts.  An alert belongs to only one activity.
A comment can belong to one risk.  A risk can have many comments.

If that's all correct, the one thing I can find is you named a column in comments activities_id vs activity_id.  It seems the schema is made for ruby on rails, so you might want to correct that to follow rails standards.
0
 

Author Comment

by:jonathan1978
ID: 37769596
I write it out in plain english, and see it this helps.

There are 3 types of User (Parent,Teacher,Student) Parent can see their Students, and their Student's teachers.
student can see their Parent, and their teachers. Teacher can see all their students, along with their parents.  All users have the same atributes (User table).

Each User has one or zero photo (profile pic).  A Photo can have many users ??? (that does not sound right)

Activities will have one photo. Same photo can be used for many activities. (Category does not have a photo. that is wrong in the category table.)

Each Activity can have only one Category.  A Category can be in one or many Activities.

A Comment can have only one Category. A Category can have many Comments.

A Comment can have only one Activity. An Activity can have many Comments.

A Comment can have only one Risk. A Risk can have many Comments.

An Activity can have Many Alerts.  An Alert can have many Activities.

How would i modify my ERD to reflect these relationships. ??
0
 
LVL 24

Expert Comment

by:johanntagle
ID: 37769636
There are 3 types of User (Parent,Teacher,Student) Parent can see their Students, and their Student's teachers.
student can see their Parent, and their teachers. Teacher can see all their students, along with their parents.  All users have the same atributes (User table).

What happens when a parent is also a teacher and other cases where a user can belong to one or more types?  Will you allow it?  If not then there won't be a need for the User_relationships table, just have a user_type_id in Users.  Then I will add a teachers_students table containing teacher_id and student_id.  This is assuming a student can have many teachers, as well as the obvious case of a teacher having many students.  For the students-parents relationship, I think it's better to just have a parent1_id and parent2_id in Users (assuming you will recognize at most 2 parents, and these will be just null if the user is just a teacher or just a parent).

Each User has one or zero photo (profile pic).  A Photo can have many users ??? (that does not sound right)

Yeah when I first saw it I thought maybe it would be for something like tagging users to a picture, but then that would require a join table.  If a photo can only belong to one user, then you should remove the 1..* relationship there.

Activities will have one photo. Same photo can be used for many activities. (Category does not have a photo. that is wrong in the category table.)

Each Activity can have only one Category.  A Category can be in one or many Activities.

A Comment can have only one Category. A Category can have many Comments.

A Comment can have only one Activity. An Activity can have many Comments.

A Comment can have only one Risk. A Risk can have many Comments.

An Activity can have Many Alerts.  An Alert can have many Activities.

Looks like you have this covered well.
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 

Author Comment

by:jonathan1978
ID: 37769720
Hi, Thanks for your help with this. I've updated my diagram.  I not understanding the users, user_type, teacher_student tabels,  as well as parent_1_id,parent_2_id in the users table. ?

We won't allow a parent to be a teacher to answer your question.

I think i might be getting the users wrong, think i am confusing myself the more i think about it. I'll try and write what users do in plain english again, and see if you can help out.

Just to give more details on the users.

This is going to be an app for kids with a disability.  All users regardless of type, all have the same functionality (can view,add an activity, category, alert, make a comment etc). They all have the same atributes, (firstname,Lastname,email,password, address, photo etc , (teachers address would probably be the school address))

A students profile, will have their parents name, email, and phone number.  A Student, Parent, and Teacher can all view the student's profile.  

At school Students will have many activities(classes), each activity will have a teacher.  It is these teachers that are linked and can view all information about a student in that activity.  A Teacher linked to a student, can add/view comments on this student.   Teachers do not have access, cannot see students from other activities.

Parents obviously can only see their own student, and teachers comments, risks, alerts on that student.  For each teacher linked to a student, the Parent's will be able to see that teachers contact phone, email.  Students would not see teachers contact details.

does this make sense to you? let me know if you need more clarification.

For relationships then :

A Student will have one or many parents. Parents can have one or many students.
A Student can have many teachers. A Teacher can have many students.

Not sure how to write this
Parents will have many students's teachers.  Teachers will have many student's parents. ?



ERD Version 2
0
 
LVL 24

Accepted Solution

by:
johanntagle earned 500 total points
ID: 37769826
modified erdSee attached.  Since a user can have only one type, it's a simple foreign key relationship between users and user_types.  Then between student and parent, since you can only have at most 2 parents, a parent_1_id and parent_2_id in users in a self referencing relationship works.

Now with students and teachers, the way I see it the direct relationship is actually between students and activities and teachers and activities.  That's why I put a teacher_id in activity.  Then the relationship description is actually a student can have many activities and an activity can have many students, which you implement using a join table activities_students.

You don't have to define an actual relationship between teachers/activities and students, because they are not directly related.  It's enough that you show the activity-student and student-parent relationships.  The teacher viewing the parents will be handled in the application, which will make use of the two relationships.
0
 
LVL 3

Expert Comment

by:Rameshwar Vyevhare
ID: 37781261
Here very small mistake i found you might know it but wants to show you-
1. activity_id instead activities_id (You should follow rails rule)
2. spell mistake in photos near created_at, it reflect creaated_at

these are very small changes I found when i saw first after looks OK.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now