I'm creating a simple database for a school. I currently have 2 forms namely frmStudents and frmGrades. I use grades to refer to grade 1, 2, 3, .., 12 rather than exam grades. The frmGrades contains the fields grade (primary key) and Fees. The frmStudents contains ID (primary key), name, grade, fees etc. The ID is an auto-generated number, name is text, and grade is linked to the field grade in frmGrades.
I'm intending to first use frmGrades to enter all grades and the corresponding fees. Then I'll enter students information into frmStudents choosing one of the grades from the grades list. My problem is how do I autopopulate the fees value based on the chosen grade?
I need to achieve this in VBA but I'm not familiar with the language at all. In psuedocode this is what I'm trying to achieve:
Private Sub frmStudents_Grade_AfterUpdate()
frmStudents.Fees.text = "Select Fees from frmGrades where frmGrades.Grade = frmStudents.Grade"
End Sub
I hope my question is clear. Thanks in advance.
First, do you really want to do this? The fee is already available in Grades, so do you need it in Student? If you do, is it because the fee changes? Also, won't the student have a different fee and grade each year, so you will want a third table:
StudentID
Date
Grade
Fee
However, if your design is really so simple, include the fee as a column in a combo for grades and update the textbox bound to the student fee from the combo column.
Grade combo on student form
Row Source: SELECT Grade, Fee FROM Grades ORDER BY Grade
Bound Column : 1
Column Count : 2
Column Widthes: 2,0
After update
Me.txtFee = Me.cboGrade.Column(1)
Related
I have IT homework that is due at midnight tonight. For our assignment, we had to create a table in an SQL database off my school AFS database. I am using MobaXTerm to do this homework assignment.
I created a table name "student". I created the entire table correctly. It is correct, because my professor gave me the exact command to create it. Here are the columns in order: id, firstname, lastname, address, state, gpa, credits. I populated this table with 20 students, however I do not want to post the picture of the result on here, because it has personal info on it.
I answered the other questions correctly, however I am stuck on this question that has multiple questions in it:
Next, write and run (issue) SQL queries that do the following. For each query, provide screenshots for the SQL query and the results within a Word document so I can grade it.
a. Show state and gpa information about students with the first name Peter (I was told to add students with the name "Peter" before I created this table).
This one is correct here is the command i used:
select state, gpa, firstname from student where lastname = 'Peter';
b. Retrieve the last names, state, and credits of all students that are NOT from AZ or FL. Order by the state.
I am struggling on this one, because I do not know how to show the table of students that are both NOT from AZ and FL.
But here is a command that worked to show if they are not from one state.
select, lastname, credits, state from student where state != 'AZ'
How am I supposed to write that student is not equal to both AZ and FL?
c. How many students live on '10 Main Street'?
select id, address from student where address='10 Main Street';
This question is correct.
d. Retrieve all sophomore student ids along with their credits that are NOT C students (see the table for definition for “sophomore” and “C” grades).
So the table shows that a sophomore has 33-64 credits. A C student has a GPA of 1.7-2.69. So what is my line of command to show these range of numbers?
Q: How am I supposed to write that student is not equal to both AZ and FL?
... WHERE state != 'AZ' AND state != 'FL'
Q: How many students ...
SELECT COUNT(*) AS count_students FROM ...
Q: Sophmore not C
... WHERE credits >= 33 AND credits <= 64
AND NOT ( gpa >= 1.7 AND gpa <= 2.69)
Im making a system for a school and I have this mySQL tables. The names are self explanatory:
student: id name course_id
course: id name
subject: id name
subject_course: id subject_id course_id
grade: id type grade
grade_type: id name
I need to check if every student of a certain course has a grade of type X on every subject that is related with that course.
Let's say grade_type = 'written test'. So I need to check if every student of 1st grade has a grade on the written test on EVERY subject related to first grade (example: math, spanish, history, etc). If yes, I do some stuff. If not, another.
Is there a query that can check that? I was thinking on check student by student but I think is less efficient.
This schema doesn't seem to make sense.
Why would course_id be field on student table? My guess is you need a student_course table to represent a many-to-many relationship between students and courses here.
Also, the grade_type table seems kind of trivial and extra overhead with little value. Could type not just be an enum on grade table?
Recently I was asked to design a portal where students can upload their technical skills like: HTML, PHP, C++ etc. and college can search the students based on the mandatory and optional skills.
Initially I thought of storing the student and their related skills details using a two columned table where first column represents the student and second column consists of all the skills related to that student separated by comma. For example,
001 HTML,C,C++,JAVA
002 C,JAVA
003 HTML,.NET
...
...
But now I'm facing problems in querying and searching for the student who have relevant skills. I tried a lot but end up with no clue on how this can be achieve.
Any pointers on storing techniques and searching algorithms etc. would be helpful. Help is much appreciated.
Thanks
A simple way to handle this is to have three tables. The first table contains students and includes a unique ID for each student. The second table contains skills and has a unique ID for each skill. The third table is for cross-referencing the first two and has two columns: "Student ID" and "Skill ID".
E.G. Let's say the skill table has an entry for "C" with ID 1, and for "C++" with an ID of 2. We have a student with an ID of 1 who knows both C and C++. We put two entries in cross-reference, the first entry has a student ID of 1 and a skill ID of 1, the second entry has a student ID of 1 and a skill ID of 2.
When you need to find out what skills a student has you just find all the rows in the cross reference table for that student ID. Conversely, if you want to find out what students have a certain skill you just find all the rows with that skill ID.
I have three tables names are Courses, EnrolledCourses and Student.
Courses table has fields namely coursenumber, coursedescription, courseunits, courseprerequisite, yearlevel (yearlevels of students who are supposed to take the course), and semester (semester in which a course is to be offered).
Students table has fields namely studID, studName, studStatus (or the year level), and studCourse.
EnrolledCourses table on the other hand has fields namely studID, courseNumber, remarks, and yearEnrolled.
QUESTION:
Suppose one of the courses or subjects taken by a student in the first semester is English101 but the student wasn't able to pass it. For this matter, English102 is to be offered for the second semester and English101 is its prerequisite course. What if i want to view all the courses for the second semester that this particular student should enroll EXCEPT the course for the second semester having a prerequisite courses that this student didn't pass. The remarks attribute from the EnrolledCourses table contains values as to whether course/prerequisite course is "Passed" or the otherwise.
I seriously need an answer to this question. If you really wanna help on this, email me at markydspark#gmail.com. THANKS!
Example Scenario: Let say I only have 2 types of buyers for a product house.
Buyer 1: Individual Buyer
Buyer 2: Company Buyer
Distinct for Buyer 1 attributes: FName, LName, Bdate and Age
Distinct for Buyer 2 attributes: Company_Name, Nature_Of_Business and Type_Of_Business
Common for the 2 Buyers are: Address, Email, Tel_No, Country
Db Table Name: Buyer
Attributes: BuyerID, BuyerType **FName,LName,Bdate,Age**,Company_Name, Nature_Of_Business and Type_Of_Business
My Explanation: If you try to see the table Buyer, both the attributes of Individual and Company buyer are merged because they are all buyers they are just categorized base on BuyerType(Individual or Company)
Issue: If the buyer type is a Company then my Individual Attributes(i.e.FName,LName etc.) will be recorded empty or vice versa. My thoughts prevents me to separate them because I DON'T want to create Buyer's ID for each table.They should have only 1 BuyerID whether they are Individual or a Company.
Problem: How to construct DB Table(s) to solve this query:
I want report that shows all the buyers information with no empty records.
Sounds crazy but when the possible report will be generated, the details might give empty records of the Individual buyer fields if the buyer is type Company
Note: This can be done easily if I will filter specific Buyer type but that is not the case. I want all.
You can calculate age from birth date, so there's no need to store the age.
You have a buyer table and separate individual buyer and company buyer tables.
Buyer
------
Buyer ID
Buyer Type
Buyer Type ID
Address
Country
Email
Telephone Number
Individual Buyer
----------------
Individual Buyer ID
Last Name
First Name
Birth Date
Company Buyer
-------------
Company Buyer ID
Company Name
Type of Business
Nature of Business
Buyer Type is an indicator that points to the particular sub table for this buyer. 'I' for individual and 'C' for company would be one way to define the indicator.
Buyer Type ID is the foreign key to either Individual Buyer ID or Company Buyer ID.
The SQL to get all the buyer information would be
SELECT *
FROM Buyer, "Individual Buyer", "Company Buyer"
WHERE "Buyer ID" = 12345
AND (("Buyer Type ID" = "Individual Buyer ID") AND ("Buyer Type" = 'I'))
OR (("Buyer Type ID" = "Company Buyer ID") AND ("Buyer Type" = 'C'))
If you want more than one Buyer row, adjust the WHERE clause.
Your logical schema will probably have three distinct entities: an abstract Buyer that contains all common fields, and two subentities that inherit from it: Individual Buyer and Company Buyer.
How you implement that schema physically is up to you. Usually, all logical entities that share the same primary key (here buyerID) will be merged in the same physical table.
Having a single table makes sense:
from a performance point of view: filtering takes less resources than joining generally. DML will also be a lot faster with a single table.
from an integrity point of view: it is very easy to insert invalid data when you have multiple tables. For instance, it is hard to guarantee that a buyerID has at least one and at most one row in the subentities if you have three tables.
I would go for a single physical table with constraints:
CREATE TABLE buyer (BuyerID primary key, BuyerType,
FName,LName,Bdate,
Company_Name, Nature_Of_Business, Type_Of_Business,
CONSTRAINT individual_chk
CHECK (BuyerType = 2 OR (Company_name IS NULL AND
Nature_Of_Business IS NULL AND
Type_Of_Business IS NULL)
),
CONSTRAINT company_chk
CHECK (BuyerType = 1 OR (...))
)
The check constraints would also validate that the required fields are not null for each type.
You can then create views if you need access to individual and business separately:
CREATE VIEW individual_buyer IS
SELECT BuyerID,
FName,LName,Bdate
FROM buyer
WHERE buyerType = 1
CREATE VIEW company_buyer IS
SELECT BuyerID,
Company_Name, Nature_Of_Business, Type_Of_Business
FROM buyer
WHERE buyerType = 2