C# What sort of data structure for this

dal

dal

Associate
Joined
10 Sep 2005
Posts
905
Location
Lincolnshire
Hi all, I've got some data that I want to group together like in the image below.
So hopefully it's clear how I want the data set out, "JUNCTION" could be considered the main item, maybe a class with a list of taxi's, each taxi would contain aircraft size(string or enum), entry ( int ),Exit (int)

I will likely want to access data in the folowing way.

Medium aircraft would need to know Entry and exit numbers for taxi 1
A few things to note :
1. Occasionally the entry/ exit numbers could change
2. Somtimes another taxi would be added or one might be removed.

Thanks.



MON0pGQ.png
 
I'd set up the database like this:
bDs0y1d.png

The only information needed from the database is the Entry + Exit numbers so I wouldn't bother creating any classes in c# for that. Just query the database and store the 2 values needed.
 
Thanks, I'm not really familiar with databases, would this be a seperate file that my code links to ? How would I go about implementing that.

EDIT : I should have added that the data will be local. It's for use in Unity.

Cheers
 
Ah, I see. Really, it's best to store data in a database but if these Entry + Exit numbers are the only data your application is going to store then maybe it's not required for your case.
You could store it in a csv or xml file or something like that. It would be simpler to do but still give some of the benefits of an external data store.

The problem with hard coding the values into your c# code is that you can't change them easily - you'd need to recompile/rerun/reinstall/etc to change the values. Maybe that's not a problem for what you're doing but it's best to avoid if possible.
 
Create class(s) for the data models, function to populate the class data, then can just alter the function if you need to alter the data. Or alter data in code.

Depending on how much data there is though a datastore of some kind would probably be better.
 
Back
Top Bottom