In the application I wrote for a small, not-for-profit, they would have 1 Guest record representing 1 person. That particular person could have many visits or stays at the facility. I had originally intended this database to have a one-to-many relationship, which it would lend itself to very well, however, I couldn’t quite figure out how to do that. I’m not a DBA.
The code below, is in the data access layer on an Entity Framework (SQL Server) database. It consists of a Guest table and a Visits table. Each visit key is differentiated by only the guest’s visit number. At times, the business layer needs all of the guests visits, sometimes, only a single visit, whether it be their last or another specific visit.
The business layer contains the following code to process the returned tuple. As you can see, the tuple(s) returned contain the Guest record and a LIST<> of all their visits. Doing it this way, allows for a FOREACH to process the visit data for one particular guest.
- public Tuple<Guest, List<VisitData>> guest_tuple;
- public List<Guest> discharges = new List<Guest> ();
- public List<VisitData> lastmonth = new List<VisitData> ();
- public List<bd_List> bed_List = new List<bd_List> ();
- public GuestsDAL dal = new GuestsDAL ();
As you can see, you can use tuples for data other than numbers and quite well, also. Hope I’ve helped or gave an idea to someone today with this meager advice.