I'm writing a game that is played in a pseudo-Internet like environment. I'm just doing the "DNS" to the game. Basically, a database which links strings ("URLs") to machines (another entity in the database).
Pretty much like in real life:
- Each machine can have zero or more urls
- Each url has a tld. For simplicity, there are only TLDs and no TLDs with more than one extension (uhh, fix my terminology there?). So .com and .net is valid, but .co.uk and .org.uk isn't.
- urls can have zero or more subdomains
- Each subdomain can be linked to a different machine
- Each subdomain can have zero or more subdomains, each linking to different machines
My first instinct was to do something like this:
domain_
tld table;
tld_id, tld
domain_hostname table;
hostname_
id, hostname, tld, parent
In which, hostname was the URL, tld links to the domain_
tld, parent is null if it's the root domain name. If it's a subdomain then parent is the parent's hostname_
id, and the hostname is the subdomain. But then I realised that it's being assigned a redundant tld... Though I suppose that could just be given a null value.
I was wondering if there were any smarter ideas?