Hello Guy's,

I came to this forum looking for help on creating a schema for a new app I'm building.

In this app I have 3 tables

Database schema
Users, Classes and Students

Now I need to provide the following functionality in my application

  • A User can be the Teacher of many Classes
  • A class can have many teachers
  • A User can also have Access to many Classes
  • A Class can have many users that have access to it

However when a user is the teacher of a class, he automaticly has access to this class. BUT
if you have access to A class this doesn't mean that you are the teacher of this class.

Why am I asking this?

Well a teacher can add grades or scores to the diffrent students that belong to the classes he has access to. He can also view the file about this students.

If you just have access to a certain class you can only VIEW grades and VIEW the files.

What's the solution?
That's the part where you come in? I was thinking of maybe two assosiation tables

teachers_class_assn

  1. user_id
  2. class_id


access_class_assn

  1. user_id
  2. class_id

But this just feels wrong....

Limitations

  1. MYSQL 5
  2. PHP 5
  3. Framework can't generate ORM for assn tables with more than 2 columns

All help is appreciated.

Sorry for my bad english

you may want to have a table like this:

user_session
1. user_id
2. session_id
3. access (either S or T)

And this one will let you have multiple instances of the same class (for example, one of the fall and one for the summer)
session
1. class_id
2. datestart
3. dateend
4. timestart
5. timeend
6. maxstudents

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.