For a school project I'm trying to keep track of students (subclass of person), their attendance (eg. wednesday 27-02-2019), and the days they are expected (eg. every monday and wednesday). There are only 5 possible combinations of expected days.
So far I've created a table Person with a discriminator for Student, and a table Attendance with a bridge table between Person and Attendance.
I have no idea how to keep track of the days they are expected to show up.
The administrator should be able to get a list of students per day, students per expected day combination (eg. Monday & Wednesday is a possible combination) and attendance per student.
I'm struggling to figure out how to store the expected days, my first guess was creating a list with 2 elements, but since this isn't allowed in SQL, I have no idea what other options I have since creating another table for days feels kind of wrong because I already have a table for attendance.
Related
I wrote an windows form app in c# that makes a presence/delay log for employees and now I'm trying to add a feature to that app which does the following :
Takes the log of that day (who is present and who came late to work) from it's database and assign it to the date of that day, so i'd be able to view one each separate day who was present and who came late to work.
To make it more clear :
Workers table : where 1 means the employee is present or delayed
ID--name----------presence-----delay
1--sam--------------1----------0---
2--jack-------------0----------0---
3--ted--------------1----------1---
Date table :
Day---------------present----delay-----absent
14/10/2012---------sam--------ted-------jack
------------------------ted-----------------------
and so on, i hope i made my idea clear.
how will the second table look like and how will the relation be ?
how will i view the result like the one in the date table ?
--Person-- --Presence-- --Delay--
ID ID ID
Name Date Date
// other info PersonID PersonID
IsPresent
First of all, you should hold Person table separately and use it's ID in other tables. I strongly recommend reading about data redundancy and database normalization. PersonID in the other tables refer to ID in Person table.
I think Presence should be logged for each day. Delay should be logged if only the Person shown up late that day.
you may want to do something like this, may not be 100% but should get you going in the right direction. Run into any other questions let me know will help as i can
table: Employees { Id, Name }
table: Logs {EmployeeId, DateCreated, OnTime (bit false if late)}
select Name
Status = CASE WHEN OnTime = 1 THEN "On Time"
WHEN OnTime is null THEN "Absent"
ELSE "Late"
from Employees as e
left join Logs as l
on e.Id = l.EmployeeId
Where l.DateCreated = #aDate
or l.DateCreated is null
to show the data the way you are looking to would then become a task for the report engine or a pivot table depending on the requirements
I'm having issues within a site that I recently took over. It is a school site that uses a table where students can reserve seats for classes. The issue I'm running into is that the classes disappear the day of and students think the class is canceled. The customer wants the class to be visible until the day after the class is over. I'm not really sure how tables like this work in ASP.Net. Any help would be great.
PCC Public Safety
Not much to go on, but first thing that comes to mind.
now() <= '1/1/2014'
Actually means Midnight on the Jan 1st 2014. If they have all day to signup, try somthng like:
now() <= '1/1/2014 23:59:59'
That will give them until midnight on the day.
I am working on doctor scheduler page requirement. The below is the screen for showing a usual weekdays schedule for a doctor.
The doctor may visit only few days on a week and only between a period of time
A doctor may be on leave some day. They add that entry
I need to design the database table to handle above scheduling.
I have no idea how a database table can be designed for 7 days with hours and doctors mapped.
The most important thing is for a given week i should be able to check the doctor availability.
I created a DoctorLeave table below to handle only doctor leave days
DoctorId, LeaveDate, Comment
But, How do i design scheduler table? Any idea/suggestions pls
I’d go with a structure that looks like this
-Doctor_ID
-Patient_ID
-Activity_Start
-Activity_End
-Activity_Type_ID
For activity type I’d create a lookup table that could look like this
Activity_Type_ID Activity_Description
1. Working with patients
2. Absent
Your table for scheduling should be simple. All you need are doctor_id, patient_id, begin_time, end_time (both fields containing both date and time). Then your query or UI code figure out which day of the week those lie on and how to display them on a schedule table, etc.
You should create a separate table for doctor unavailability. doctor_id, leave_begins, leave_ends (both as dates and times if necessary). Once again, use your queries or UI code to figure out conflicts during appointment scheduling.
I have recently started developing using ASP.NET and am struggling to grasp Code-First. I am working on a project for an internship and have very little database knowledge except for one class I've taken. I am in no way asking for a complete solution or being lazy.
I've been trying for a couple days to create a solid ER diagram and I'm fairly certain the one below will represent all of the information I need to store. Please let me know if you see any ways this can be improved.
What I'm trying to do:
For this project an administrator will create rooms with attributes listed below. The admin will then assign time-slots that represent between what hours the room will be available and what days of the week it will be available.
The users will fill out their basic information and fill out a form representing what times they are available.
After all the users have registered the admin will run a scheduling algorithm to come up with the closest to a most efficient schedule that it can (because it's NP hard).
The assigned relation represents user time slots that are related to room time slots in order to produce a table of what users are assigned to what rooms at what times.
I'm using Visual Studio 2012.
Questions
How would I represent these aggregate entities using Code-First? Not necessarily asking for the code for this exact diagram but maybe quick example to help me wrap my head around Code-First.
Do my mappings look correct for these relations?
Any help or point in the right direction is greatly appreciated!! Thank you!
Below is an ER diagram that represents the following:
Room (id, number, building, capacity)
TimeSlot (id, startHour, endHour, dayOfWeek)
User (id, firstName, lastName, email)
Available (userId, timeID)
Reserved (roomID, timeID)
Assigned (reservedID, availableID)
Firstly in the ER diagram I would have expected a link directly from Room to TimeSlot (top-right) and User to Timeslot (bottom right), but knowing the likely queries that will be run I would suggest the ERD should be as follows.
Room linked to an entity called RoomAvailability. RoomAvailability contains all the free time slots for rooms, so this will initially be populated with one record per room per day (RoomId, Date, StartTime, EndTime) going to as many days into the future as you think necessary.
Similarly I would have an entity UserAvailability (UserId, Date, StartTime, EndTime) linked to User.
Entity RoomReservation (RoomId, UserId, Date, StartTime, EndTime) linked to both Room and User which contains all room reservations (assumes only 1 user can book a room).
When a room is reserved a RoomReservation records is added and a single RoomAvailability record may be split into 2 separate ones (e.g. room is free for whole day then someone books a slot during the day leaving 2 free periods at the start and end of the day).
When a reservation is cancelled the RoomReservation record is deleted and 2 RoomAvailability records may be merged back into 1 (the reverse of the above).
I believe that splitting and merging of available slots is how similar systems work.
I want to create counters in MySQL database that stores the number of views per products in a specific day, month and year.
The problems is that I have around 2000 products. I thought about using the following schema:
id (BIGINT)
year (INT[4])
month (TINYINT)
day (TINYINT)
product_id (INT)
pageviews (BIGINT)
The problem with that solution is that if, in the worst case scenario, each product is viewed each day, I will have 2000 rows in my database each day. Multiply is by 36 days and I will have 72,000 each month.
I wanted to know if there is a better way to implement this. I thought that the daily data will be kept only in memory as Application variable (developing in .NET) and as ArrayList. IF I chose that direction, I will have less rows/data, 2000 rows each month.
I really want to keep the cumulative daily page-views. By the way, previews is just for illustration purposes, I will store different data, but that data will be updated very frequently.
If I use the daily column, it will be update very often, almost every 2-5 seconds. I intend to update MySQL async by calling an ASP.NET webservice from Javascript, passing the product_id and increase the counter +1. That's to prevent the application to wait for the update to occur.
I also want to know the estimate table size. IF I'm doing it right:
BIGINT = 8 bytes
Datetime = 10 bytes
INT - 4 bytes
^if I decide to go with a datatime column instead of year/month/day
30 bytes * 2000 = 60,000 bytes
60KB (approx.) * 30 days = 180KB month
180KB month * 12 months = 2160KB / year
Did I get it right?
Ok I'm not that great in Database design but I know that much...
you should ask yourself for how long you want to save the daily hits on these 2K products?
If you want to hold them just for a week then you can calculate how much it'll take in Size (also if you want to hold them for a month).
If you want to save it for let's say a month then you could always make a table each month and save the data from the daily hits to that table and sum them up so you'll have only 2K rows in each table
Or you could use a "warehouse" table that will hold all the hits per let's say month and every month the data will be copied to that warehouse table after you sum it up for each month.
If you want these hits to be saved indefinitely then that is the way as far as I know (Again not a master in Database design).
Again this is what you should do if you want to save the hits up to a month.
Hope I helped you,
Sagi.