Click here to Skip to main content
15,877,857 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 .
Posted
Updated 3-Mar-16 22:11pm
v2

1 solution

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)
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900