学生数据库的出勤入口需要查询数据库创建 [英] Attendance entry for students database need query for database creation

查看:70
本文介绍了学生数据库的出勤入口需要查询数据库创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有60名学生姓名和每日出勤率,为学年。如何创建数据库查询。但是不想每次都在数据库中创建许多列



我尝试了什么:



i尝试创建表但不应该这样做。

i have 60 students name and daily attendance,for academic year.how to create database query.But dont want to create many columns in database every time and every day

What I have tried:

i tried like creating table but it is not supposed to do that way .

推荐答案

你不这样做:你创建了几个表格。

第一个表格包含学生:

You don't do it that way: you create a couple of tables instead.
The first table holds the students:
ID        Can be INT, IDENTITY (that way SQL will deal with ensuring it is unique), PRIMARY KEY
Name      NVARCHAR(50) shoudl be fine



第二个表保持出勤率:


The second table holds attendance:

ID        INT, IDENTITY (To make sure each row is unique), PRIMARY KEY
StudentID INT, FOREIGN KEY (Relates back to the actual Students table)
Attended  DATE (Date they attended)

然后,对于参加的学生,您在第二个表中创建一个新行从第一个表到学生,并记录它们出现的日期。

然后使用WHERE和SQL JOIN来检索您感兴趣的记录。

Then for a student attending, you create a new row in the second table which refers to the student from the first table, and logs the date they were present.
You then use WHERE and an SQL JOIN to retrieve the records you are interested in.


这篇关于学生数据库的出勤入口需要查询数据库创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆