Solved Yearss (1 Viewer)

Mercy Mercy

Member
Local time
Today, 14:43
Joined
Jan 27, 2023
Messages
87
Actually I am defeated. I am looking for a query to show students and classes and streams.

I created sub forms like this.

Look at relationships.

Main form- tblstudents.

Subform1- frmgradeyears.

Subform 2- frmgradestream.

Now my question is
When I create a query it puts a student in all streams.

I don't whether the problem is referential integrity or not?

Kindly assist.

Attached is a database.
 

Attachments

  • STUDENTS.accdb
    640 KB · Views: 84

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:43
Joined
May 21, 2018
Messages
8,529
Your relationships are fine, but your data seems jacked up. What is going on here? You need a unique index on GradeID and StreamID so that there are not multiple
1,1
1,1
1,1
1,2
1,2
1,2
Also Does each grade get every stream?

tblGradeStream tblGradeStream


tblGradeStreamIDGradeIDStreamID
12​
1​
2​
1​
2​
4​
1​
3​
5​
1​
1​
9​
1​
2​
11​
1​
3​
13​
1​
1​
14​
1​
1​
16​
1​
1​
18​
1​
1​
20​
1​
1​
21​
1​
1​
22​
1​
1​
3​
2​
2​
6​
2​
4​
10​
2​
4​
15​
2​
3​
17​
2​
1​
19​
2​
2​
8​
3​
3​
7​
4​
2​
 

Mercy Mercy

Member
Local time
Today, 14:43
Joined
Jan 27, 2023
Messages
87
Thanks for your advice. Kindly assist me. Please. I am new in access.
 

Mercy Mercy

Member
Local time
Today, 14:43
Joined
Jan 27, 2023
Messages
87
Your relationships are fine, but your data seems jacked up. What is going on here? You need a unique index on GradeID and StreamID so that there are not multiple
1,1
1,1
1,1
1,2
1,2
1,2
Also Does each grade get every stream?

tblGradeStream tblGradeStream


tblGradeStreamIDGradeIDStreamID
12​
1​
2​
1​
2​
4​
1​
3​
5​
1​
1​
9​
1​
2​
11​
1​
3​
13​
1​
1​
14​
1​
1​
16​
1​
1​
18​
1​
1​
20​
1​
1​
21​
1​
1​
22​
1​
1​
3​
2​
2​
6​
2​
4​
10​
2​
4​
15​
2​
3​
17​
2​
1​
19​
2​
2​
8​
3​
3​
7​
4​
2​
Let us take for example we have 8 students in grade 1.

Student A should be in grade 1 RED.

Student B should be In grade 1 WEST

Student C should be in Grade 1 NORTH.

Student D should be in grade 1 SOUTH.

Student E should be in grade 1 YELLOW

Student F should be in grade 1 ORANGE

Student G should be in grade 1 GREEN

Student H should be in grade 1 ZEBRA


So in this case we have one grade and 8 streams.
. Therefore we have 8 students in grade 1.

Thanks in advance.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:43
Joined
May 21, 2018
Messages
8,529
Again that data is jacked. You cannot have that table with only one student in the database.
Provide a useable set of test data and your query.

My mistake. But that is confusing.
Answer the question. Can a student be in more than one stream?
If only one stream per student per grade your one table should include
StudentId_fk
Gradeid_fk
Streamid_fk
And index these as a unique if multiple streàms per grade per student. If only one stream then index student and grade.
 
Last edited:

mike60smart

Registered User.
Local time
Today, 12:43
Joined
Aug 6, 2017
Messages
1,905
Let us take for example we have 8 students in grade 1.

Student A should be in grade 1 RED.

Student B should be In grade 1 WEST

Student C should be in Grade 1 NORTH.

Student D should be in grade 1 SOUTH.

Student E should be in grade 1 YELLOW

Student F should be in grade 1 ORANGE

Student G should be in grade 1 GREEN

Student H should be in grade 1 ZEBRA


So in this case we have one grade and 8 streams.
. Therefore we have 8 students in grade 1.

Thanks in advance.
Take a look at the attached.

The query1 produces the output you require.
 

Attachments

  • STUDENTS.zip
    43.9 KB · Views: 76

Mercy Mercy

Member
Local time
Today, 14:43
Joined
Jan 27, 2023
Messages
87
@mike60smart I am requesting you to look at the attached database and assist me come up with referential integrity between students and teachers. Assist me with query to show for example in year 2023, teacher A is a class teacher for grade 1 RED for example.

I am humbly requesting you. Please. Please. Please.
 

Attachments

  • STUDENTS and TEACHERS.zip
    79.4 KB · Views: 81

mike60smart

Registered User.
Local time
Today, 12:43
Joined
Aug 6, 2017
Messages
1,905
Hi

I think you need to rethink your table relationships.

In a specific Year I take it you have a number of Streams, with each Stream comprising a number of Students.

Is this the case?
 

Mercy Mercy

Member
Local time
Today, 14:43
Joined
Jan 27, 2023
Messages
87
Hi

I think you need to rethink your table relationships.

In a specific Year I take it you have a number of Streams, with each Stream comprising a number of Students.

Is this the case?
True. Example 2023
Grade 1 red- 37 students
Grade 1 green- 40 STUDENT.
Grade 1 ORANGE- 54 students
Grade 1 north- 43 students

We also have teachers teaching those classes
 

mike60smart

Registered User.
Local time
Today, 12:43
Joined
Aug 6, 2017
Messages
1,905
In a specific Year you have a number of Terms.

So in a Specific Year for Each Term there are a number of Streams with a number of Students in Each Stream
 

Mercy Mercy

Member
Local time
Today, 14:43
Joined
Jan 27, 2023
Messages
87
Yes. And in each term different EXAMINATIONS are done for several subjects
Year- 2023
Grade 1- grade 1 RED
Grade 1 YELLOW
Grade 1 north
Term - term 1
Examination- WEEKLY EXAMS.
SUBJECTS.

TEACHERS.
 

mike60smart

Registered User.
Local time
Today, 12:43
Joined
Aug 6, 2017
Messages
1,905
Would it be better to say:-

In a specific Year there are a Number of Terms.
Each term has a Number of Grades (Does grades equate to Kindergarden, Primary , Secondary??)
Each Grade has a Number of Students with each Student in a specific Stream
 

Mercy Mercy

Member
Local time
Today, 14:43
Joined
Jan 27, 2023
Messages
87
Would it be better to say:-

In a specific Year there are a Number of Terms.
Each term has a Number of Grades (Does grades equate to Kindergarden, Primary , Secondary??)
Each Grade has a Number of Students with each Student in a specific Stream
Correct
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:43
Joined
Feb 19, 2002
Messages
43,275
You need to remove StudentID from tblGradeYears. tblGradeYears defines the universe of your grade structure. Then you need a junction table to connect students to grade years. The junction table would be named tblStudentGradeYears. It would contain an autonumber PK and the two FKs StudentID and YearGradeID. Then you need a unique index on the two PKs. Open the indexes dialog. On the first blank line add a name for the index name. It must be unique. Then pick the first field - StudentID and set the index to be unique. Go to the next line. Skip the index name field and pick the second field - YearGradeID. Leaving the index name blank is the way you tell Access that the two fields are part of a multi-field index. in tblGradeYears, you also need a unique index. on the three fields - GradeYearID,GradeID, and StreamID.

You also have a different problem with indexes on tblGradeYears. You have created indexes on GradeID, GradeYearID,StudentID, and StreamID. ALL of these indexes MUST be deleted. All of these fields are foreign keys to some other table. When you define relationships, Access automagically creates HIDDEN indexes on every FK. Therefore you have duplicated the indexes and this doubles the work to manage the indexes and also has the potential for corruption so just get rid of them. Leave the PK but remove the other four indexes.
 

Mercy Mercy

Member
Local time
Today, 14:43
Joined
Jan 27, 2023
Messages
87
You need to remove StudentID from tblGradeYears. tblGradeYears defines the universe of your grade structure. Then you need a junction table to connect students to grade years. The junction table would be named tblStudentGradeYears. It would contain an autonumber PK and the two FKs StudentID and YearGradeID. Then you need a unique index on the two PKs. Open the indexes dialog. On the first blank line add a name for the index name. It must be unique. Then pick the first field - StudentID and set the index to be unique. Go to the next line. Skip the index name field and pick the second field - YearGradeID. Leaving the index name blank is the way you tell Access that the two fields are part of a multi-field index. in tblGradeYears, you also need a unique index. on the three fields - GradeYearID,GradeID, and StreamID.

You also have a different problem with indexes on tblGradeYears. You have created indexes on GradeID, GradeYearID,StudentID, and StreamID. ALL of these indexes MUST be deleted. All of these fields are foreign keys to some other table. When you define relationships, Access automagically creates HIDDEN indexes on every FK. Therefore you have duplicated the indexes and this doubles the work to manage the indexes and also has the potential for corruption so just get rid of them. Leave the PK but remove the other four indexes.
I am now confused more than before.
 

Users who are viewing this thread

Top Bottom