April 29, 2020 at 12:50 pm
I have a pretty "dumb" question, but I want to get the consensus on this
I have a table that is going to store Location data (address, geocoding, etc). Location is a reserved word in SQL Server and I have always lived by "do not pluralize a object name". Anyone have suggestions on naming this object?
April 29, 2020 at 1:37 pm
https://www.thesaurus.com/browse/location
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
April 29, 2020 at 2:19 pm
Maybe LocationAddress if you're primarily looking at attributes of an address?
April 29, 2020 at 2:50 pm
I prefer to name my address tables "whereDeyAt", my individual identifier table "whoDey" and the transaction table showing activities "whazzzaaaaaaaap" (I alias that one, it's long)
-------------------------------------------------------------------------------------------------------------------------------------
Please follow Best Practices For Posting On Forums to receive quicker and higher quality responses
April 29, 2020 at 5:28 pm
You could use "location" still, but put []'s around it too. My habit is to put [] around my objects. Never know when a new version of SQL will add a new feature to it and suddenly my code fails because I used a NEW reserved keyword.
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.
April 29, 2020 at 5:43 pm
You could use "location" still, but put []'s around it too. My habit is to put [] around my objects. Never know when a new version of SQL will add a new feature to it and suddenly my code fails because I used a NEW reserved keyword.
We hate this idea.
Sincerely,
everyone who has to code against this table
-------------------------------------------------------------------------------------------------------------------------------------
Please follow Best Practices For Posting On Forums to receive quicker and higher quality responses
April 29, 2020 at 5:59 pm
Mr. Brian Gale wrote:You could use "location" still, but put []'s around it too. My habit is to put [] around my objects. Never know when a new version of SQL will add a new feature to it and suddenly my code fails because I used a NEW reserved keyword.
We hate this idea.
Sincerely,
everyone who has to code against this table
As someone who does code verification for SQL code (and does database development), there are tools that will do this automatically for you. And, personally, I would rather have my own safeguards in place rather than just trust that the people who are testing the databases prior to a production upgrade are going to catch everything.
Imagine you were working on a SQL 2000 database and you made a column called DBCC. The time comes for you to upgrade to 2005 (or higher), all of your code that used that column would need to be modified because in 2005 DBCC became a reserved keyword.
I imagine you fall into the group that doesn't put a ; at the end of your statements either, right?
Side note - Location is not a reserved keyword:
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.
April 29, 2020 at 6:06 pm
While your assumption of my incompetence probably would save you time somewhere, no, I do not fall in that group of people. Also, bite me.
Just because there are ways to get around bad ideas doesn't mean people shouldn't realize they are bad ideas. Naming things based on keywords is a Bad Idea (tm).
In this case, per your research, that may not be the case.
-------------------------------------------------------------------------------------------------------------------------------------
Please follow Best Practices For Posting On Forums to receive quicker and higher quality responses
April 29, 2020 at 7:57 pm
I prefer to name my address tables "whereDeyAt", my individual identifier table "whoDey" and the transaction table showing activities "whazzzaaaaaaaap" (I alias that one, it's long)
BWAAAA-HAAAA-HAAAA!!!! SNNNOOORRRRTTT!!!! NOW THATS FREAKIN' FUNNY!!!! 😀 Heh... and being old where "It Depends" has two significant meanings, I have to tell you a semi-colon just won't do. 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
April 29, 2020 at 8:17 pm
While your assumption of my incompetence probably would save you time somewhere, no, I do not fall in that group of people. Also, bite me.
Just because there are ways to get around bad ideas doesn't mean people shouldn't realize they are bad ideas. Naming things based on keywords is a Bad Idea (tm).
In this case, per your research, that may not be the case.
I apologize for that implication; what I was trying to imply was that you preferred to not include ;'s in SQL code as they are not required. Nothing about your competency with SQL code. I've seen some very competent SQL coders not use ;. I have seen some competent SQL coders not indent their code. I was just making a comment about coding habits of developers.
My experience with developers (myself included) is if something isn't explicitly required, it is often excluded. It is VERY easy to get into the habit of NOT including ;'s in your SQL code because it is not required and then you end up with the ugly ; prefix on CTEs or inconsistent use of ;'s.
My preference is still to name SQL objects with a name that makes the most sense for the content. I try to avoid keywords in production ready code, but I am not always successful when working quickly or working in test or with queries from this forum (as can be seen in some of my other posts, especially when working with grouping of rows). I am also REALLY bad at naming my CTEs and cursors. CTE's often get names like "cte1, cte2, cte3" which would never make it onto a production system and my cursors are often things like "cursewords, thisisabadidea, dontusethis, fixlater".
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.
April 29, 2020 at 9:55 pm
I have a pretty "dumb" question, but I want to get the consensus on this
I have a table that is going to store Location data (address, geocoding, etc). Location is a reserved word in SQL Server and I have always lived by "do not pluralize a object name". Anyone have suggestions on naming this object?
It seems the thread kind of got off track a bit...
I would recommend separating out multiple 'location' tables as in AddressLocation, GeocodingLocation, etc... with location information specific to each type - or, your single 'location' table be renamed as Region or Locale or Locality or other synonym. If you really want it identified as Location then add a prefix/postfix (e.g. Location_Lookup).
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
April 30, 2020 at 6:16 pm
There are some standards for naming data elements in RDBMS.. Look at the Metadata Committee, and ISO 11179 standards. The basic principle, however, is that you should name something for what it is by its nature. Not by how it is stored or where it is stored. Try to use industry standards whenever possible (it almost always is)
For example, a table should not be named "employee", unless you really do have only one employee since a table models a set, it should be a plural ("employees") or collective noun ("Personnel"); the collective noun is usually better for this. The reason that some people use singular names is that the original pre-relational modeling systems, like IDEF, were based on filesystems and record at a time processing. But in RDBMS, the "unit of work" is not a record, but an entire table.
The preferred format for naming a data element is "[<role>_]<attribute name>_<attribute property>". For example, the table in which the data element resides might be "forest" and the rows in the table would be zero or more examples of particular trees (yes, in RDBMS tables can be empty, but files cannot).
A roll is with the same attribute appears twice or more in a query or other statement. For example, using personnel, we might have "supervisor_employee_id", which shows that this employee identifier plays a role of supervisor. This way you don't get them confused with a mere "employee_id".
Another thing is that if you look at the ISO standards for all of their encodings, the only portable identifiers among all of the standards use Latin alphabet, digits, the underscore (and some limited punctuations) and NO spaces between the parts. This will let your data element names work with virtually any programming language on earth.
Please post DDL and follow ANSI/ISO standards when asking for help.
April 30, 2020 at 7:10 pm
Joe,
instead of employees, I'm wondering what your thoughts are around the Party model. I know you get a lot of grief here, but this is a legitimate question.
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
May 1, 2020 at 1:42 pm
What is the "party model"? Can you give me an example, using personnel in a generic organization?
Please post DDL and follow ANSI/ISO standards when asking for help.
May 1, 2020 at 2:01 pm
create table Geolocation (...)
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply