I am making an MVC application that requires daily readings which are organised into weeks, which are in turn organised into years. I have a week entity, and a day entity, which are tables of weeks and days respectively. Is there any way I can link the days to a WeekNo
but not have WeekNo
or DayNo
as the primary keys?
For example, there'd be 5 working days in week 1:
WeekNo = 1, DayNo = 1
WeekNo = 1, DayNo = 2
WeekNo = 1, DayNo = 3
WeekNo = 1, DayNo = 4
WeekNo = 1, DayNo = 5
Then when Week 2 comes along:
WeekNo = 1, DayNo = 1
But then there is a duplicate of Day 1.
I am having a similar problem with the weeks in a year, that when the next year comes along and it's back to Week 1, there's a duplicate in weeks. But if I can get past this, maybe I would be able figure that out too.
How would I go about referencing these to each other?
Day
model:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Utility.Models
{
public class Day
{
public int DayID { get; set; }
public int WeekNo { get; set; }
public int DayNo { get; set; }
public string DayofWeek { get; set; }
public float Reading1 { get; set; }
public float Reading2 { get; set; }
//etc
public virtual Week Week { get; set; }
}
}
Week
model:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations.Schema;
namespace Utility.Models
{
public class Week
{
public int WeekID { get; set; }
public int WeekNo { get; set; }
public int YearID { get; set; }
public virtual Year Year { get; set; }
public virtual ICollection<Day> Days { get; set; }
}
}