Solved Yearss (1 Viewer)

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:25
Joined
Feb 19, 2002
Messages
43,275
I made a lot of nit-picky changes to the schema but you should also check each table because I may have missed stuff.
1. I removed 0 as the default for FK's. 0 is never valid so the default should be null
2. I changed the setting of the AllowZLS from yes to no for all the fields involved in the little lookup tables. I did not fix the teachers table or the other fields in the student table. In general, I ALWAYS change the AllowZLS property to No because I prefer that fields that are empty be null. That way I can always test for null and not have to worry about what data type a field is. Remember, dates and numbers are NOT STRINGS and so the AllowZLS doesn't apply to them since they can never contain a ZLS. It also prevents the problem with fields like LastName. If you have AllowZLS set to yes, the user can enter a blank name and even if the field is defined as required, Access will allow it which makes no sense. So, always change this property to No just on GP (general principles)
3. I removed all the extraneous indexes on the FK fields. When you create a relationship using the relationship window, Access automagically creates a HIDDEN index on the FK fields so you do not need to and should not create a second one.
4. The relationship between TermStreams and Students was backwards so I removed the StudentID from TermStreams and added the FK to TermStreams into Students
5. I renamed the Students table for consistency. Consistency is your friend. It will save you lots of hair pulling and head banging.
6, I added unique indexes to the text fields on the lookup tables. I don't like the way this is broken down but since it is not technically wrong, I didn't change it. I just fixed it to work correctly. I also made these fields required. So on tables like Years, Terms, Grades, etc. there is a unique index on the "text" field AND the "text" field is marked as required. It makes absolutely NO SENSE to have a row in one of these tables if it doesn't have a "text" field value. It also makes no sense for the "text" field in any of these tables to be duplicated so I added the unique index.
7. I added a new column to the Years table and named it Prior. If you will look at the frmStudents, you will understand why. I added a combo box so that the TermStreamID could be selected. Look at the RowSource query and you will see WHY I dislike this structure. But in any event, I made a concatenated name to make it easy for someone to pick the right TermStream. The query sorts the prior years to the bottom of the list but leaves them there and out of the way. I also added code to the Form's BeforeUpdate event to prevent a user from picking a TermStream for a prior year.
8. I also cleaned up the related tables of Term Streams. GradeStream existed but wasn't being used correctly so I used it correctly. I don't like it but again, it isn't wrong to have this as an intermediary table.


1, 2, 3, 5, 6 are things you need to learn to do by rote. You NEVER want to deviate. I have code I can run to clean up Access' default mess after I create a table. It is in one of my examples so I'll include a link to it. But the code cannot clean up your sloppy choices regarding allowing duplicates and not using indexes correctly. That takes discipline and some time to make it second nature so you don't even think about it.

Things I didn't fix
1. The frmYears and it's subforms. There was no point in doing that if I didn't fix the schema correctly.
2. I didn't fix all the poorly formed names. Names should contain ONLY letters, numbers, and the underscore. No embedded spaces, no special characters and also NO VBA function or property names. The link above includes a form that shows some of what bad things happen when you include non-standard characters in object names. Access INMNSHO, is way too lax regarding table, column, and object names. It is this laxness that causes you more work later. Access does it to be "friendly" to new users but in reality, this "friendliness" just causes problems down the line when you start writing code and queries.

Things I recommend that you change.
1. The attachment data type is one of those abomination fields that can't be upsized. I assume you are using them for photos of students and teachers. Unless you are planning on storing multiple images, I would just get rid of the attachment data type and save yourself some later agnst. Just use the OLE object type instead to hold ONE image. Better still, use a text field and store a link to the image. That will save a lot of database bloat that will start to affect the database after a few years of use. If you are storing multiple indexes, just make a child table and put the images in that so you can support multiples. Change your form to use a subform to show the child table with the OLE objects rather than using the attachment control. You get exactly the same functionality without having to learn a new variant of SQL or having a problem should you ever want to upsize the BE to sQL Server. And it is no more work if you do it from the start.
 

Attachments

  • STUDENTS and TEACHERS_Pat.zip
    116.7 KB · Views: 97
Last edited:

Mercy Mercy

Member
Local time
Today, 10:25
Joined
Jan 27, 2023
Messages
87
As Pat says we all try to help each other. I don't mind being told when I am wrong as I am still learning at 77 years old.

The attached is a redesigned Structure which may still be wrong.
You can select the Year
Then select the Required Term
Select or enter a Student
Then select the Subject
Last but not least Enter Weeks & Examination Types.

Let us know if this covers your process or if we are way off the mark.
Thanks @mike60smart I appreciate
 

Mercy Mercy

Member
Local time
Today, 10:25
Joined
Jan 27, 2023
Messages
87
I made a lot of nit-picky changes to the schema but you should also check each table because I may have missed stuff.
1. I removed 0 as the default for FK's. 0 is never valid so the default should be null
2. I changed the setting of the AllowZLS from yes to no for all the fields involved in the little lookup tables. I did not fix the teachers table or the other fields in the student table. In general, I ALWAYS change the AllowZLS property to No because I prefer that fields that are empty be null. That way I can always test for null and not have to worry about what data type a field is. Remember, dates and numbers are NOT STRINGS and so the AllowZLS doesn't apply to them since they can never contain a ZLS. It also prevents the problem with fields like LastName. If you have AllowZLS set to yes, the user can enter a blank name and even if the field is defined as required, Access will allow it which makes no sense. So, always change this property to No just on GP (general principles)
3. I removed all the extraneous indexes on the FK fields. When you create a relationship using the relationship window, Access automagically creates a HIDDEN index on the FK fields so you do not need to and should not create a second one.
4. The relationship between TermStreams and Students was backwards so I removed the StudentID from TermStreams and added the FK to TermStreams into Students
5. I renamed the Students table for consistency. Consistency is your friend. It will save you lots of hair pulling and head banging.
6, I added unique indexes to the text fields on the lookup tables. I don't like the way this is broken down but since it is not technically wrong, I didn't change it. I just fixed it to work correctly. I also made these fields required. So on tables like Years, Terms, Grades, etc. there is a unique index on the "text" field AND the "text" field is marked as required. It makes absolutely NO SENSE to have a row in one of these tables if it doesn't have a "text" field value. It also makes no sense for the "text" field in any of these tables to be duplicated so I added the unique index.
7. I added a new column to the Years table and named it Prior. If you will look at the frmStudents, you will understand why. I added a combo box so that the TermStreamID could be selected. Look at the RowSource query and you will see WHY I dislike this structure. But in any event, I made a concatenated name to make it easy for someone to pick the right TermStream. The query sorts the prior years to the bottom of the list but leaves them there and out of the way. I also added code to the Form's BeforeUpdate event to prevent a user from picking a TermStream for a prior year.
8. I also cleaned up the related tables of Term Streams. GradeStream existed but wasn't being used correctly so I used it correctly. I don't like it but again, it isn't wrong to have this as an intermediary table.


1, 2, 3, 5, 6 are things you need to learn to do by rote. You NEVER want to deviate. I have code I can run to clean up Access' default mess after I create a table. It is in one of my examples so I'll include a link to it. But the code cannot clean up your sloppy choices regarding allowing duplicates and not using indexes correctly. That takes discipline and some time to make it second nature so you don't even think about it.

Things I didn't fix
1. The frmYears and it's subforms. There was no point in doing that if I didn't fix the schema correctly.
2. I didn't fix all the poorly formed names. Names should contain ONLY letters, numbers, and the underscore. No embedded spaces, no special characters and also NO VBA function or property names. The link above includes a form that shows some of what bad things happen when you include non-standard characters in object names. Access INMNSHO, is way too lax regarding table, column, and object names. It is this laxness that causes you more work later. Access does it to be "friendly" to new users but in reality, this "friendliness" just causes problems down the line when you start writing code and queries.

Things I recommend that you change.
1. The attachment data type is one of those abomination fields that can't be upsized. I assume you are using them for photos of students and teachers. Unless you are planning on storing multiple images, I would just get rid of the attachment data type and save yourself some later agnst. Just use the OLE object type instead to hold ONE image. Better still, use a text field and store a link to the image. That will save a lot of database bloat that will start to affect the database after a few years of use. If you are storing multiple indexes, just make a child table and put the images in that so you can support multiples. Change your form to use a subform to show the child table with the OLE objects rather than using the attachment control. You get exactly the same functionality without having to learn a new variant of SQL or having a problem should you ever want to upsize the BE to sQL Server. And it is no more work if you do it from the start.
@Pat Hartman I apologize from the heart. I am really sorry for my previous comments. I am very very very very very very sorry. I hope I am forgiven. I have realized that you had no ill intentions. Thanks @Pat Hartman for going an extra mile assisting me with a sample database. I really really really really really really appreciate.

Once again thank you @Pat Hartman

TruceπŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™
 

mike60smart

Registered User.
Local time
Today, 08:25
Joined
Aug 6, 2017
Messages
1,905
This is Pats database modified slightly to allow the following:

1. Select a specific Year
2. Select a specific Term
3. Select a specific Grade / Stream
4. Allows the display of a Number of Students for the Grade/Stream selected
5. On selection of a Student be able to specify the Subject and then add all relevant Weeks, Exam Types & Marks.

I would imagine there are errors.
 

Attachments

  • STUDENTS and TEACHERS_Pat.zip
    145.7 KB · Views: 73

Mercy Mercy

Member
Local time
Today, 10:25
Joined
Jan 27, 2023
Messages
87
This is Pats database modified slightly to allow the following:

1. Select a specific Year
2. Select a specific Term
3. Select a specific Grade / Stream
4. Allows the display of a Number of Students for the Grade/Stream selected
5. On selection of a Student be able to specify the Subject and then add all relevant Weeks, Exam Types & Marks.

I would imagine there are errors.
Thanks so much. I appreciate. I had also modified and it is working fine. Thanks @mike60smart and @Pat Hartman I really really really appreciate πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™πŸ™
 

mike60smart

Registered User.
Local time
Today, 08:25
Joined
Aug 6, 2017
Messages
1,905
Can we see your modified version?

There are still things wrong which need to be resolved.
 

Mercy Mercy

Member
Local time
Today, 10:25
Joined
Jan 27, 2023
Messages
87
Can we see your modified version?

There are still things wrong which need to be resolved.
True. There is a problem with tblTeachers it says "related record in tbl teachers."
Just seeking advice.
What if I create a junction between tblTeachers and tbltermsubjects and also another junction between tblstudents and tblTeachers and tblDormitories.

Please advise.

Thanks in advance.
 

mike60smart

Registered User.
Local time
Today, 08:25
Joined
Aug 6, 2017
Messages
1,905
True. There is a problem with tblTeachers it says "related record in tbl teachers."
Just seeking advice.
What if I create a junction between tblTeachers and tbltermsubjects and also another junction between tblstudents and tblTeachers and tblDormitories.

Please advise.

Thanks in advance.
Upload the database so we can see
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:25
Joined
Feb 19, 2002
Messages
43,275
What if I create a junction between tblTeachers and tbltermsubjects and also another junction between tblstudents and tblTeachers and tblDormitories.
Junction tables are NOT optional. They are used whenever you have a many-many relationship. Can you have multiple teachers teaching the same subject during the same term? Yes, but I didn't see that as a possiblity given your last schema. Students do not have a direct relationship to teachers. Students relate to a class via a junction table and the class relates to a teacher. Students only live in ONE dormitory at a time so again, this is NOT a m-m relationship.

Relationships are not ARBITRARY. They model real life. They are what they are and if you use the wrong schema to represent them, you will not be representing reality.
 

Mercy Mercy

Member
Local time
Today, 10:25
Joined
Jan 27, 2023
Messages
87
Junction tables are NOT optional. They are used whenever you have a many-many relationship. Can you have multiple teachers teaching the same subject during the same term? Yes, but I didn't see that as a possiblity given your last schema. Students do not have a direct relationship to teachers. Students relate to a class via a junction table and the class relates to a teacher. Students only live in ONE dormitory at a time so again, this is NOT a m-m relationship.

Relationships are not ARBITRARY. They model real life. They are what they are and if you use the wrong schema to represent them, you will not be representing reality.
Thanks @Pat Hartman
 

Mercy Mercy

Member
Local time
Today, 10:25
Joined
Jan 27, 2023
Messages
87
This is Pats database modified slightly to allow the following:

1. Select a specific Year
2. Select a specific Term
3. Select a specific Grade / Stream
4. Allows the display of a Number of Students for the Grade/Stream selected
5. On selection of a Student be able to specify the Subject and then add all relevant Weeks, Exam Types & Marks.

I would imagine there are errors.
This database works very fine. However, I want to create a main form from tblstudents and subforms being
1. frmStreamStudentssubform.
2. frmTermStreamssubform.
3. frmTermSubjectssubform.
4. frmSubjectExamWeekssubform.

Thanks in advance πŸ™πŸ™πŸ™πŸ™πŸ™
 

mike60smart

Registered User.
Local time
Today, 08:25
Joined
Aug 6, 2017
Messages
1,905
Well I think you should be able to work this out from the examples given
 

Users who are viewing this thread

Top Bottom