473,473 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Automatic inserts (given count variables from another table)

STUDENT TABLE
StudentReference [pk]
Student Name
etc
ATTENDANCE TABLE
AttendanceID [pk]
CourseID [fk]
StudentReference [fk]
Session_Date
Session_Start_Time,
Session_End_Time,
Total_Hours
COURSE TABLE
CourseID [pk]
CourseName
CourseDescription
HoursRequired

COURSE STUDENT LINK
CourseStudentLinkID [pk]
CourseID [fk]
StudentReference [fk]

It's work I've been doing for a learning center.
Voluntary stuff - but I said I'd get it working.

Anyway, originally, they just wanted to put students and what courses
they've been on. But they wanted to extend this to show the times of
sessions they're in and then if they've done enough hours for the course.

Anyway, there's about 1500 odd students, so attaching each student to each
course is going to be a nightmare. People have been entering session times
[to the attendance table]
in (data entry) over the summer - but because people are only assigned onto
a course if they've attended at least 1 sessions - then we get a problem.
So, what we need is.

Insert StudentReference CourseID (from the attendance table) into Course
Student Link IF there are >=1 occcurences of StudentReference CourseID.

SO for example,

if Dave Winchester has listed 1 or more attendance of a course grapefruit
engineering, then

Dave Winchester [StudentReferecence] and[ CourseID] need to be placed into
the COURSE STUDENT LINK table.

I've tried this

insert into Course_Student_Link (StudentReference, CourseID)
select StudentReference, CourseID
from Attendance_Table
where
(select count(distinct StudentReference, CourseID)
from Attendance_Table) => 1
insert into Course_Student_Link (StudentReference, CourseID)
select StudentReference CourseID
from Attendance_Table
where Total_Hours => 1
but the syntax is wrong :-(
Anyone got any ideas?
Nov 13 '05 #1
4 1681
"m_houllier" <mh********************@nildram.co.uk> wrote in message news:<41***********************@mercury.nildram.ne t>...
STUDENT TABLE
StudentReference [pk]
Student Name
etc
ATTENDANCE TABLE
AttendanceID [pk]
CourseID [fk]
StudentReference [fk]
Session_Date
Session_Start_Time,
Session_End_Time,
Total_Hours
COURSE TABLE
CourseID [pk]
CourseName
CourseDescription
HoursRequired

COURSE STUDENT LINK
CourseStudentLinkID [pk]
CourseID [fk]
StudentReference [fk]

It's work I've been doing for a learning center.
Voluntary stuff - but I said I'd get it working.

Anyway, originally, they just wanted to put students and what courses
they've been on. But they wanted to extend this to show the times of
sessions they're in and then if they've done enough hours for the course.

Anyway, there's about 1500 odd students, so attaching each student to each
course is going to be a nightmare. People have been entering session times
[to the attendance table]
in (data entry) over the summer - but because people are only assigned onto
a course if they've attended at least 1 sessions - then we get a problem.
So, what we need is.

Insert StudentReference CourseID (from the attendance table) into Course
Student Link IF there are >=1 occcurences of StudentReference CourseID.

SO for example,

if Dave Winchester has listed 1 or more attendance of a course grapefruit
engineering, then

Dave Winchester [StudentReferecence] and[ CourseID] need to be placed into
the COURSE STUDENT LINK table.

I've tried this

insert into Course_Student_Link (StudentReference, CourseID)
select StudentReference, CourseID
from Attendance_Table
where
(select count(distinct StudentReference, CourseID)
from Attendance_Table) => 1
insert into Course_Student_Link (StudentReference, CourseID)
select StudentReference CourseID
from Attendance_Table
where Total_Hours => 1
but the syntax is wrong :-(
Anyone got any ideas?


I think you don't need a course_student_link table, if you generate it
dynamically using a Query of the following type: (in not fully
qualified form)

"Select StudentReference, CourseID, sum(Total_Hours), Hours_Required
from Attendance_table inner join Course_Table on
(Attendance_table.courseID = Course_table.CourseID)
Group by StudentReference, CourseID, Hours_Required
having sum(Total_hours) => 1"

or "having sum(total_hours) >= Hours_required" when only qualified
students should be filtered

A query in this form can be easely created without extensive SQL
knowledge through the query editor using the totals-option (the
sigma-button) and working out the filter- and aggregation options in
the QBE-fields.

The query above could be used in a create-table query and the
result-table could replace the link-table.

Marc
Nov 13 '05 #2
"m_houllier" <mh********************@nildram.co.uk> wrote in message news:<41***********************@mercury.nildram.ne t>...
STUDENT TABLE
StudentReference [pk]
Student Name
etc
ATTENDANCE TABLE
AttendanceID [pk]
CourseID [fk]
StudentReference [fk]
Session_Date
Session_Start_Time,
Session_End_Time,
Total_Hours
COURSE TABLE
CourseID [pk]
CourseName
CourseDescription
HoursRequired

COURSE STUDENT LINK
CourseStudentLinkID [pk]
CourseID [fk]
StudentReference [fk]


I think you're missing a table. First off, I would split
Session(SessionID, CourseID, SessionStartDateTime,SessionEndDateTime,
[totalHours]) off from Attendance.

Attendance might look like this:
CREATE TABLE Attendance(
SessionID,
StudentID,
....
PRIMARY KEY (SessionID, StudentID)
FOREIGN KEY (SessionID) REFERENCES (Session.SessionID),
FOREIGN KEY (StudentID) REFERENCES (Student.StudentID);

Then you'd record hours on the Class/Section level and not the student
level, unless they can get something like partial credit for going to
half the class.
Nov 13 '05 #3
The hours work,
I mean, a query based on StudentID, CourseID along with some calculations on
the form side provide the user with the information of how many hours have
been attended on each specific course and if they've passed (based on
hours).

In the way it works at the moment - the problem is creating this table of
course_student_link

I'll strip the data out of the database (data protection and all that), then
upload so you can see what I mean :-)

if you'd be kind enough to look that is :D

"Pieter Linden" <pi********@hotmail.com> wrote in message
news:bf*************************@posting.google.co m...
"m_houllier" <mh********************@nildram.co.uk> wrote in message

news:<41***********************@mercury.nildram.ne t>...
STUDENT TABLE
StudentReference [pk]
Student Name
etc
ATTENDANCE TABLE
AttendanceID [pk]
CourseID [fk]
StudentReference [fk]
Session_Date
Session_Start_Time,
Session_End_Time,
Total_Hours
COURSE TABLE
CourseID [pk]
CourseName
CourseDescription
HoursRequired

COURSE STUDENT LINK
CourseStudentLinkID [pk]
CourseID [fk]
StudentReference [fk]


I think you're missing a table. First off, I would split
Session(SessionID, CourseID, SessionStartDateTime,SessionEndDateTime,
[totalHours]) off from Attendance.

Attendance might look like this:
CREATE TABLE Attendance(
SessionID,
StudentID,
...
PRIMARY KEY (SessionID, StudentID)
FOREIGN KEY (SessionID) REFERENCES (Session.SessionID),
FOREIGN KEY (StudentID) REFERENCES (Student.StudentID);

Then you'd record hours on the Class/Section level and not the student
level, unless they can get something like partial credit for going to
half the class.

Nov 13 '05 #4
For the time being, hours attained is calculated on the form side. For
instance, timediff is used to record how many hours each session was, and
then in the form they are added together

eg,

HEADER date of session, start time , end time, total hours
DATA 19/04/03 9am 12pm 3
DATA 20/04/03 10am 12pm 2 (late git!)
DATA 21/04/03 9am 12pm 3

Hours required 40 Hours attained 8

If the hours aren't attained I use conditional formatting (make it a really
mean red), and if they're inside then it's green.
"Select StudentReference, CourseID, sum(Total_Hours), Hours_Required
from Attendance_table inner join Course_Table on
(Attendance_table.courseID = Course_table.CourseID)
Group by StudentReference, CourseID, Hours_Required
having sum(Total_hours) => 1"
The last part of that Group by ..... (Total_hours) => 1" I'm not so sure
about. I was convinced that I'd need count or dcount as part of this
solution.

But I see where you're going with the sum(Total_Hours) and dynamic table
idea. I'll give that a bash as one deviation of attempted solutions :-)

cheers Marc,

"Marc" <M.***********@uva.nl> wrote in message
news:ae**************************@posting.google.c om... "m_houllier" <mh********************@nildram.co.uk> wrote in message

news:<41***********************@mercury.nildram.ne t>...
STUDENT TABLE
StudentReference [pk]
Student Name
etc
ATTENDANCE TABLE
AttendanceID [pk]
CourseID [fk]
StudentReference [fk]
Session_Date
Session_Start_Time,
Session_End_Time,
Total_Hours
COURSE TABLE
CourseID [pk]
CourseName
CourseDescription
HoursRequired

COURSE STUDENT LINK
CourseStudentLinkID [pk]
CourseID [fk]
StudentReference [fk]

It's work I've been doing for a learning center.
Voluntary stuff - but I said I'd get it working.

Anyway, originally, they just wanted to put students and what courses
they've been on. But they wanted to extend this to show the times of
sessions they're in and then if they've done enough hours for the course.
Anyway, there's about 1500 odd students, so attaching each student to each course is going to be a nightmare. People have been entering session times [to the attendance table]
in (data entry) over the summer - but because people are only assigned onto a course if they've attended at least 1 sessions - then we get a problem.

So, what we need is.

Insert StudentReference CourseID (from the attendance table) into Course
Student Link IF there are >=1 occcurences of StudentReference CourseID.

SO for example,

if Dave Winchester has listed 1 or more attendance of a course grapefruit engineering, then

Dave Winchester [StudentReferecence] and[ CourseID] need to be placed into the COURSE STUDENT LINK table.

I've tried this

insert into Course_Student_Link (StudentReference, CourseID)
select StudentReference, CourseID
from Attendance_Table
where
(select count(distinct StudentReference, CourseID)
from Attendance_Table) => 1
insert into Course_Student_Link (StudentReference, CourseID)
select StudentReference CourseID
from Attendance_Table
where Total_Hours => 1
but the syntax is wrong :-(
Anyone got any ideas?


I think you don't need a course_student_link table, if you generate it
dynamically using a Query of the following type: (in not fully
qualified form)

"Select StudentReference, CourseID, sum(Total_Hours), Hours_Required
from Attendance_table inner join Course_Table on
(Attendance_table.courseID = Course_table.CourseID)
Group by StudentReference, CourseID, Hours_Required
having sum(Total_hours) => 1"

or "having sum(total_hours) >= Hours_required" when only qualified
students should be filtered

A query in this form can be easely created without extensive SQL
knowledge through the query editor using the totals-option (the
sigma-button) and working out the filter- and aggregation options in
the QBE-fields.

The query above could be used in a create-table query and the
result-table could replace the link-table.

Marc

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: L. Blunt | last post by:
Hopefully someone can at least point me in the right direction for more research (e.g.: correct terminology). My only previous experience was just dumping data into a database using ODBC, and that...
3
by: Viswanatha Thalakola | last post by:
Hello, Can someone point me to getting the total number of inserts and updates on a table over a period of time? I just want to measure the insert and update activity on the tables. Thanks....
5
by: Peter van Rijn | last post by:
Having my SQL-background in Oracle I'm looking for the MySQL equivalent for: update tableA set column1=(select count(*) from tableB where tableA.key= tableB.key) cannot find anything similar...
10
by: Forest14 | last post by:
Hello! Happy Christmas/holidays to you all I have this huge table named "Positions" with more than 160 fields of which the fields are named with non obvious abbreviations. I have another table...
1
by: jlrolin | last post by:
I'm trying to update a new field in a table from a COUNT(*) of Registration IDs grouped by Course IDs. COUNT: Course_ID 11 1234 12 2323 19 8932 ...
1
by: mharis | last post by:
I'm using MS SQL and I'm challenged with how update a table based on the count of records from another. I have a couple transactions for an id and I want to count total number and multiply by 4 or...
0
by: acesfull | last post by:
Hi, I am trying to do something in SQL that I have done in PHP, but I am trying to have the operation performed as a stored procedure because of the sheer number of inserts I have to perform in PHP. ...
1
HaLo2FrEeEk
by: HaLo2FrEeEk | last post by:
I've got a table where I store tips for a challenge. Its structure is this: tip_id, challenge_id, user_id, ip_address, tip_date, tip_text The tips can be voted up or down, I store vote data in...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.