how to define relationship in access - ms-access

I want to create a form for dataentry in access. I am confused about defining the tables. I have a Student table, which includes information about student first name, last name, etc.
I have information about technical skills which has different groups (6 groups) programming, languages,banking, etc. Each group has different parts: for example, Programming has 4 parts JAVA, PHP, C, Python.
Languages also have different parts English, German, Spanish, French
Banking has these parts: Risk Management, Project Management
Each student has different skills; first student knows Java, php, German, Project Management
How many tables should I define and how go I relate them to the main Student table?

I would go with the following structure:
tblStudent
ID (PK)
FirstName
LastName
tblStudent_Skill
Student_ID (PK)(FK)
Skill_ID (PK)(FK)
tblSkill
ID (PK)
SkillName
SkillType_ID (FK)
tblSkillType
ID (PK)
SkillTypeName
tblStudent - only information relating to this specific person, name, address, phone, etc.
tblStudent_Skill - linking table to deal with many-many relationship between tblStudent and tblSkill.
tblSkill - specific skills, for example PHP, English, Python, Maths, etc.
tblSkillType - category list for Skills, for example programming, languages,banking, etc.

Related

MySQL Database Normalization Advice

I'm currently designing a database for a project I have in college and I would really appreciate some feedback. Basically, the idea of the project is to create a food plants, food inventory database. I have created a schema for the database but I'm not sure if the products table abides by 3NF.
So my products table contains p_id( the primary key), the name of the product, what type is the product (eg pizza or dessert), the country it comes from, the region in that country and who the product is suitable for (eg vegan).
So basically when I break it down, I feel that Region is dependant on Country and type is dependant on the name? Would I be right in assuming this? I could then split the table into 3 separate tables. 1 which would contain p_id, name, Country and another one which would contain Country, Region and a third one which would contain name and type. Would this then be a fully normalised database up to 4NF?
Here is a my schema:

Tutors, Students, Courses database design

I have 3 entities: Tutors, Students, Courses
Tutors teach many courses
Students can be assigned to many courses that are taught by many tutors
Tutors and students need to be able to log into the system
I would like to represent this design using the following tables:
users
- id
- username
- password
- first_name
- last_name
- email
- password
- phone
- role_id (Student or Tutor or Admin)
- created
- modified
roles (Student, Tutor)
- id
- name
- created
- modified
courses (The courses that Tutors can teach and that Students can be assigned to)
- id
- name
- created
- modified
users_courses
- id
- user_id
- course_id
- created
- modified
The problem I have with the above design (users_courses table) is that, let's say we have Tutor A and Tutor B that teach Math. If student X is registered to that math course we can't know if student X is being tutored by Tutor A or Tutor B.
I would really like to be able to use a single users table to keep all the users to make things simple.
Any advice please?
The problem is that you want to handle students and teachers differently (students enroll in a course taught by a specific teacher) but you modeled them the same (they're just users).
Instead of roles, create subtypes of users. Create tables for teachers and students - you can reuse the primary keys from users, but you'll be able to handle subtype-specific attributes and relationships.
While it's possible to get away with only those entity sets, I suggest you add the concept of a section as well. It has different names in different systems or parts of the world, but most school systems I've seen have something like it to represent a partition of a course's students with an associated teacher.
users
- id PK
- username
- password
- first_name
- last_name
- email
- password
- phone
- created
- modified
students
- user_id PK FK
teachers
- user_id PK FK
courses
- id PK
- name
- created
- modified
sections
- section_id PK
- teacher_id FK
- course_id FK
- created
- modified
students_sections
- student_id PK FK
- section_id PK FK
- created
- modified
In a real world system, you'll also need to take time into account - students and teachers normally attend different courses in different years or semesters.
I would simply add the “tutor” to the courses table since it’s essential element for a course to know whose is teaching it/tutor.
Then use either the users table or user_courses to join/match and pull the info you want.
**Courses**
- id
- name
-tutorID
- created
- modified

Is there a query for this?

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?

Best technique to implement skill matrix

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.

Database: Tables design/structure

I am new to database structure and design. Currently, I am in the process of creating a course catalog that will match course description according to course name and date. I have sketched one table describing the courses, which include course_code, name and every other relevant information. Then I sketched another table linking those courses to when they will be taught.
I am missing classes that are classified as all_year. Also I am missing a way how to label the courses under a major. Since hypothetically a course can belong to several majors, putting the data from one into the other would force you to duplicate data. Any ideas how I would implement this two things to my tables design? Or suggestion in how to restructure my design. If possible please show me a query to execute in my phpmyadmin DB.
Example of table courses
id serial
course_code text
description text
Example of table course_dates
id serial
course_id serial
year date
semester
Example of table majors
major_id int
course_id int
So a populated database could contain the following:
Table courses
id course_code description
1 INF1000 "Basic programming"
2 INF1001 "More basic programming"
Table course_dates (0 for spring 1 for fall)
id course_id year semester
1 1 2012 0
2 1 2013 1
3 2 2013 1
To link courses to majors - this is a one to many relationship (one course to many majors) - you want to use a linking table that has this type of structure:
table courses_majors
major_id int
course_id int
Remember to index this table as well - its very important. Then you can populate it and have one course even go to many majors and many course to one major (many to many relationship).
Then you can run a join on the tables across this table:
select * from courses left join courses_majors on courses.id = courses_majors.course_id left join majors on courses_majors.majors_id = majors.id
Of course you can add a where clause, etc.
The other way is to create a table of majors:
majors
id int
name varchar
Then add a major_id to your courses table - this will just give you a one to one relationship from courses to majors, but many courses can join a major.
As for Yearly, I would just add a field in the database to account for this, probably a tiny int and just make it 0 or 1.