RESTFful/Resource Oriented Design

Course Queries Syllabus Queries 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

Suppose I have a three level hierarchy consisting of school, students, and classes.

If I expose student as a resource, my question is whether I should always return the parent "school" and the children "classes" along with that student, or whether there should be parm that the user includes to indicate such. Perhaps something like &deep=True?

Or on the other hand, if a user gets a student, and he wants the school, he has to do a GET on the school resource, and likewise if he wants all the classes that a student is taking, he has to do a GET on the classes resource?

I'm trying to keep the design somewhat open for the unknown future user, rather than coding just for what our current requirements demand.

Thanks,

Neal Walters

profilepic.png
manpreet 2 years ago

I think you should avoid thinking of classes as a sub-resource or attribute of a student. An academic class is more than just a time slot on a student's schedule; it has an instructor, a syllabus, etc., all of which may need to be encoded at some point.

As I see it, the following relations hold:

  • schools have zero or more students
  • schools have zero or more classes
  • students have zero or more classes
  • classes have zero or more students

(You could also trivially extend these with teachers/instructors, if your requirements included such information.)

In addition, each of the above resource types will have any number of attributes beyond the simple links between them.

Given that, I would think you'd want a URL structure something like the following:

  • http://example.com/lms/schools => list of schools
  • http://example.com/lms/schools/{school} => info about one school
  • http://example.com/lms/schools/{school}/students => list of students
  • http://example.com/lms/schools/{school}/students/{student} => info on one student
  • http://example.com/lms/schools/{school}/students/{student}/courses => list of courses (as links, not full resources) student is enrolled in
  • http://example.com/lms/schools/{school}/courses => list of courses
  • http://example.com/lms/schools/{school}/courses/{course} => info on one course
  • http://example.com/lms/schools/{school}/courses/{course}/students => list of students (as links, not full resources) enrolled in course

0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.