how does this datastructure look for a table?

TechBoyJK

Lifer
Oct 17, 2002
16,699
60
91
Hi,

I'm working on a script for my website to offer functionality similar to TinyURL.

I'm not trying to compete with them, just at least offer it as a part of the bigger site.

The site is setup to run a script anytime a call is made for a file/folder that is not physically available. The script takes the requested url and parses it out like such

www.mcdonalds.com/doesnotexist parses to 'doesnotexist'

Once this is done, it queries a table I have setup to find if there is a match for 'doesnotexist'.

If there is not a match, then it returns a 404 page not found error (custom for the site).

If there is a match, it checks a related column for another entry, which is a column that contains another URL.


Structure
---------------------
tbl_dns

dns_id (int-identity-pk)
dns_member_id (int-fk)
dns_domain (varchar-20)
dns_subdomain (varchar-30)
dns_redirect_url (nvarchar-255)
dns_date (Datetime)
dns_month_range (int)

explanation
------------------------------

dns_id (unique id, primary key)

dns_member_id (member ID of creator, 0 for anonymous

dns_domain (root domain aka company.com - here because I will use multiple domains)

dns_subdomain (what will come after company.com aka '123url' - company.com/123url )

dns_redirect_url (the url that the created subdomain will redirect to)

dns_date (the start or renew date for the domain)

dns_month_range (the length in months the redirect is to be active, will be deleted when expired)

Does this look ok?
 

aceO07

Diamond Member
Nov 6, 2000
4,491
0
76
My suggestions:
1. remove the 'dns' prefix on all your column names.
2. name tbl_dns to be more descriptive. Also remove 'tbl' prefix.
3. maybe rename 'dns_date' to be 'cycle_start' or something that has more meaning.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
I agree that the prefixes serve no purpose. If you can't figure out whether or not the name is a table name or column name based on the syntax of the code there are other problems.

Also, subdomain is a bad name for that field. A subdomain would be server5.mywebdomain.com. You are looking at the query string after the trailing slash on the TLD.
 

TechBoyJK

Lifer
Oct 17, 2002
16,699
60
91
Originally posted by: Crusty
I agree that the prefixes serve no purpose. If you can't figure out whether or not the name is a table name or column name based on the syntax of the code there are other problems.

Also, subdomain is a bad name for that field. A subdomain would be server5.mywebdomain.com. You are looking at the query string after the trailing slash on the TLD.

Ok, I'll take out the prefixes. What would be a better name for the subdomain column? QueryStringAfterTheTrailingSlashOnTheTLD? I'm not sure of a better name which is why i used subdomain.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
How about query_string? Come to think of it I'm not sure why your table is labeled DNS.

I might have included something about redirects because that's really what you are doing with the information, redirecting a request to a new location.