Database design question :) Is it smarter to make a lot of interconnected tables (normalize) or is it smarter to duplicate data so queries are simpler?
Here is my situation:
public class TransferRequest
{
[Key]
public int TransferRequestId { get; set; }
public int By { get; set; }
public int? For { get; set; }
public int PersonId { get; set; }
public virtual Person Person { get; set; }
[ForeignKey("Transfer")]
public int? ExistingTransferId { get; set; }
public virtual Transfer ExistingTransfer { get; set; }
[Required]
[Range(1, 999)]
public int Pax { get; set; }
[Range(0, 999)]
public int PaxChild { get; set; }
[Range(0, 999)]
public int PaxInfant { get; set; }
public int StartPortId { get; set; }
public virtual Port StartPort { get; set; }
public int EndPortId { get; set; }
public virtual Port EndPort { get; set; }
[Required]
[DataType(DataType.DateTime)]
[UIHint("PickupTimePicker")]
[Display(Name = "Pickup time"), DisplayFormat(DataFormatString = "{0:dd.MM.yyyy HH:mm}")]
public DateTime PickupTime { get; set; }
public bool Cargo { get; set; }
public string CargoDescription { get; set; }
public int Status { get; set; }
[ForeignKey("Transfer")]
public int? TransferId { get; set; }
public virtual Transfer Transfer { get; set; }
}
after which this is created:
public class Transfer
{
public Transfer()
{
Crew = new List<CrewOnTransfer>();
TransferPoints = new List<TransferPoint>();
TransferRequests = new List<TransferRequest>();
}
[Key]
public int TransferId { get; set; }
[ForeignKey("Ship")]
public int ShipId { get; set; }
public virtual Ship Ship { get; set; }
[ForeignKey("ShipCrew")]
public int CaptainId { get; set; }
public virtual ShipCrew ShipCrew { get; set; }
public virtual ICollection<CrewOnTransfer> Crew { get; set; }
public virtual ICollection<TransferPoint> TransferPoints { get; set; }
public virtual ICollection<TransferRequest> TransferRequests { get; set; }
}
That goes on for Crew:
public class CrewOnTransfer
{
[Key]
public int CrewOnTransferId { get; set; }
[ForeignKey("ShipCrew")]
public int ShipCrewId { get; set; }
public virtual ShipCrew ShipCrew { get; set; }
[ForeignKey("Transfer")]
public int TransferId { get; set; }
public virtual Transfer Transfer { get; set; }
}
And so on. You get the idea. Should I simplify the situation? This is getting messy to follow.