Recommended Naming Convention For Tables/columns

May 9, 2008

I did a search (google and on the forums) and found a few suggestions here and there, but I'd like something more complete to follow as far as naming conventions are concerned.

I wrote my first DB based on MySQL/Ruby/Active Record type naming convention...

- plural table names
- all lower cased
- underscores between words
- "id" is auto incrementer for each table
- something+"_at" is for datetime fields
- something+"_on" is for date fields
- referencing the primary id in another table is "tablename (singular)" + "_id".

This worked great in Ruby/MySQL, but in C#/SQL Server, its an ambiguity nightmare! All of my "id" fields conflict and alot of my tables have "added_at" datetime fields and they all conflict with each other. Essentially, any field that's named the same in one table as in another conflict on joins.

For example: users post comments to stories submitted by users...

table = articles
field 1 = id
field 2 = title
field 3 = body
field 4 = user_id

table = comments
field 1 = id
field 2 = title
field 3 = body
field 4 = user_id
field 5 = article_id

Trying to join these two tables is an ambiguity nightmare but I'd like to not have to name every field uniquely or start adding table prefixes to them all...

I guess I just need some good suggestions or links to recommended table structure/naming conventions for SQL Server. Thanks in advance!

View 3 Replies


ADVERTISEMENT

Naming Convention

Aug 21, 2006

Hi all,
I wanted to ask for the naming conventions in SQL SERVER.as in case of pl/sql server we have ..name_of_package.name_of_procedure thats how we call the procedures i.e. owner of schema then name of package n then procedure name.....i want to ask you all how is it done in SQL SERVER..please try to reply as soon as possible,
i will b waiting for the replies,
regards

View 3 Replies View Related

Naming Convention

May 8, 2006

Would like to know what naming convention you folks use.

What I need specifically is column naming conventions.

For instance, I have a table called 'lst_as400_srvr'. We could go with the vigorous:

CREATE TABLE lst_as400_srvr
(
as400_srvr_idintNOT NULLIDENTITY,
as400_srvr_namevarchar(128)NOT NULL,
as400_srvr_is_activebitNOT NULLDEFAULT 1
)

Or, I could loosen the rules a bit and go with:

CREATE TABLE lst_as400_srvr
(
idintNOT NULLIDENTITY,
namevarchar(128)NOT NULL,
is_activebitNOT NULLDEFAULT 1
)

I would lean towards the vigorous because it would be very obvious what data is being referenced by the name. In the loosened version, I could very easily have many tables with a 'id' column or a 'is_active' column.

Inversely, I would lean towards the loosened version because the names are a lot shorter and, thus, easier / faster to type.

I figure, if I'm going to learn a new standard, now's a good time to do so.

So, thoughts? Appreciate the help folks. :)

View 5 Replies View Related

Naming Convention

Feb 26, 2007

Sorry if this seems trivial, but is it allowed to add hyphens in a physical server name?
eg: PC-01


Will this cause any errors (when connecting, etc)
Thanx.

View 1 Replies View Related

Naming Convention

Dec 5, 2007



Is there any standard naming convention for SQL Server that microsoft suggest it?
the same as naming guidlines in MSDN for designing libararies in .Net Framework.

View 4 Replies View Related

Sql Table Naming Convention

Dec 20, 2003

I have to build a table Physicalcharacterics in sql.

Convention for naming a table

Would I name this table in sql server
tbl_User_PhysicalCharacterics.
My main parent table is tbl_User.


Is that too long of a name.

View 2 Replies View Related

Universal Naming Convention.

Aug 21, 2006

how can i find the servername and sharefolder on my computer to access a file?

for the server name i used the ip aand sharefolder i used computer description.
i think its not right cause its not working.

View 18 Replies View Related

How To Find Objects That Are Not Following Naming Convention

Apr 1, 2008

Hi All,

I have an assignment to change names of the SPs that are not following Standard naming convention in all databases. For this first I need to find out all the SPs that are not following naming convention. Can anybody help me in finding out the objects that are not following standard naming conventions. It is first step in completing this assignment. If anybody deal with this type of task before please guide me.
Hope any one of you will reply me with more information......

Thanks,
Pradeep

View 9 Replies View Related

SQL 2012 :: Linked Server Naming Convention?

Nov 6, 2015

How do you name sql linked-servers in your company ?

we have many legacy systems (random naming), but mostly newer systems follow this pattern

<ENVIRONMENT><APPLICATION><FUNCTION><VIRTUAL><NUMBER>

e.g.

PRD-FAX-DB-V01, TST-PAY-WEB-P02 etc.

We have link-servers all over the place. The ideal naming convention should satisfy following:

- developers should not have to modify code when deploying between environments DEV->TEST->PROD. This rules out using actual server name as linked-name.

- the name should easily identify actual server without much mental translation. This rules out relevant but generic names like FAXSERVER or PAYSERVER

- also, if the name could state that it is a linked-server e.g starting with LINK_, it works when reading the code.

So, I was thinking the link-name should simply remove the environment :

e.g LINK_FAX_DB_V01

that way, on DEV box, the underlying sql data source could point to the dev server, while on test, it could point to test server etc. without having to change code, and also knowing which server it's pointing to by just adding a TST or PRD in front-of it.

View 0 Replies View Related

Renaming All Default Contrainsts To Fit Into Naming Convention

Mar 14, 2008

I am currently trying to rename all of the Default constraints in my database to fit in with my naming convention of DF_+TableName+ColumnName. Since there are over 300 of the things, I don't particularly fancy doing them all manually.

I was hoping to use something like...





Code Snippet

--Declare the variables
DECLARE @defname VARCHAR(100), @tblname VARCHAR(100), @colname VARCHAR(100), @cmd VARCHAR(1000)

--Set the table name
SET @tblname = (SELECT object_name(parent_obj) FROM sysobjects
LEFT JOIN sys.columns ON sys.columns.object_id = sysobjects.id
INNER JOIN sysconstraints ON sysobjects.id = sysconstraints.constid
WHERE sysobjects.xtype = 'D')

--Set the column name
SET @colname = (SELECT name FROM sys.columns
INNER JOIN sys.tables ON sys.tables.object_id = sys.columns.object_id
WHERE sys.tables.name = @tblname)

--Set the default constraint
SET @defname = (SELECT name FROM sysobjects JOIN sysconstraints
ON sysobjects.id = sysconstraints.constid
WHERE object_name(sysobjects.parent_obj) = @tblname
AND sysobjects.xtype = 'D'
AND sysconstraints.colid = (SELECT colid FROM syscolumns
WHERE id = object_id(@tblname) AND
name = @colname))

--Set the renaming
SET @cmd = EXEC sp_rename +@defname+, 'DF_'+@tblname+'_'+@colname+, 'OBJECT'

--Execute the renaming
EXEC(@cmd)

I know that the above is not correct in any way, but it is how far I have got before I got really stuck! And I thought it might help you see what I was trying to get at...

Any clues?

View 5 Replies View Related

Table Name Convention For Related Tables

Nov 1, 2007

Hi,

If I have 2 tables:

TableA
aID
aCount

TableB
bID
bCount

And I need to create a 3rd table that will look like:

aID
bID

What should I call this table?

I've seen:

relAB

AXB

Any other naming conventions?

View 7 Replies View Related

Drop All Tables In Db That Have Specific Name Convention

Oct 23, 2007

I have 1000's of tables. Some are of the form dbo.VT_2006-10-12. I'd like to drop all tables with the "VT" in the table name. How is the best done?

View 6 Replies View Related

Naming Calcualted Columns

Jun 19, 2006

I have several calcuatled columns in a table (see below) that I have been work with. First can I assign a proper naming decision to the columns? How can I reference these columns in other tables?

For example how can I assign names to the columns listed below?

select date, ((abc * .05)+ efgh * .05), (((efgh * .475) + (abc * .475) + (123gross * .05)))
from table
where date = '2006-03-31

Thanks

View 15 Replies View Related

Tables, Naming Problem

Feb 14, 2008

Is there a good way to name tables that are used as lookup tables? If you have a table for movies and you think that a movie can be in more than one genre. Then you will have tables like the following.

a table for movies, table 1
id name ...
1 Scarface

a table for the movie genres, table 2
id name ...
1 action
2 mafia

a table that links the genres to the movies, table 3
id table 1 id table 2 id
1 1 1
2 1 2

Table 1 is no problem. I name it movie.
Table 2 is the genres. I name it movie_genres.
Table 3 specifies the genres for a specific movie so I name it movie_genres. Duh, already taken.

This is just an example and perhaps not the best. What should I call my to genre tables?

View 6 Replies View Related

Naming Temporary Tables With Variables

May 3, 2000

Is there a way to put a variable name into the name of a temporary table. For example, I would like to create a table called 'test@passedvariable', or test2 assuming that @passedvariable is 2. How would I go about doing this. Any help would be greatly appreciated.

Thanks,
Jon

View 3 Replies View Related

Web Service Task And Document/Literal Calling Convention

May 6, 2008

The Web Service Task seems to support calling methods using parameters but not (as far as I can see) using the Document/Literal calling convention. Is this correct? Is this likely to change in the future?

Thanks

*** Campbell

View 5 Replies View Related

SQL 2012 :: Calculated Columns Conditional On Calculated Columns Multiple Tables

Apr 20, 2014

I have 4 tables involved here. The priority table is TABLE1:

NAMEID TRANDATE TRANAMT RMPROPID TOTBAL
000001235 04/14/2014 335 A0A00 605
000001234 04/14/2014 243 A0A01 243
000001236 04/14/2014 425 A0A02 500

TRANAMT being the amount paid & TOTBAL being the balance due per the NAMEID & RMPROPID specified.The other table includes a breakdown of the total balance, in a manner of speaking, by charge code (thru a SUM(OPENAMT) query of DISTINCT CHGCODE

TABLE2
NAMEID TRANDATE TRANAMT RMPROPID CHGCODE OPENAMT
000001234 04/01/2014 400 A0A01 ARC 0
000001234 04/05/2014 -142 A0A01 ARC 228
000001234 04/10/2014 15 A0A01 ALT 15

[code]...

Also with a remaining balance (per CHGCODE) column. Any alternative solution that would effectively split the TABLE1.TRANAMT up into the respective TABLE2.CHGCODE balances? Either way, I can't figure out how to word the queries.

View 0 Replies View Related

Recommended Max Size Of 6.5 DB

May 31, 2002

I have a 6.5 database running on NT 4.0 that is approximately 43GB in used space. I am making a case to management for some sort of upgrade to the whole system.

What sizes of 6.5 databases would anyone consider more "risky"? Is 43GB large for 6.5 (my thought is that it is)?

Thanks,

Kurt Symanzik
Handleman Company

View 2 Replies View Related

Recommended DB Design

Feb 9, 2004

Let's say for instance that you have a group of tables that stores address information for different groups (i.e. Doctors, Patients, Providers, etc.) Would it be better to create each table to store the address information or create an Address table that would store this information with an Address type and a link back to each table?

I prefer the second choice, but am having a hard time convincing other devlopers to follow this route. Maybe if I have some input from a more experienced users group I can stress my point a little more effectively. Thanks in advance for any input you can provide.

View 2 Replies View Related

Two Approaches: Which One Is Recommended?

Jul 14, 2006

I need to import a CSV file with a few million records and 50 fields into a table. Only 1 column in the file needs to be transformed and a second column needs to be checked for data validity (e.g. don't want to let someone pass in 'CA' for an integer field.). Two approaches come to mind:

1. Use SSIS to read the file directly into the table, then apply t-sql to do a mass update to the single field that needs to be transformed. (with this approach it is not clear how to check the data valdity in each row via t-sql, though).

2. Use SSIS to import the file, 1 line at a time, transforming the data and checking its validity.as it goes. I suspect this approach will be much slower than that in 1) but I haven't tried it yet.

Which way do you think would be the fastest?



TIA,



barkingdog

View 3 Replies View Related

Recommended Books

Aug 22, 2005

Can somebody recoommend me books for sql server 2005. I am interested specially in CLR inside sql and Business Intelligence.   

View 4 Replies View Related

Recommended Architecture For One-Many

Jun 5, 2007



In a situation where one may have a single master SQL Server that ultimately needs to communicate information back down to 1000's of downstream servers, what is the recommended architectural approach?



It doesn't feel right to have to add 1K-5K routes to the master SQL Server. Is there a way to have the dowstream servers "broadcast" their existence to the master, so that new servers can be added and updates can happen seamlessly? Does this fall into a pub-sub scenario or is there a better way? And, if so, how to ensure an open conversation (so that one server doesn't miss information that all the other servers received)? Should the master dynamically create routes or better to rely on an open conversation initiated by the downstream server?

View 20 Replies View Related

Recommended File Locations?

Apr 23, 2001

I know I've seen documentation on this but I can't find it at the time. What's the recommended file locations for a SQL install.. System and Data on a RAID drive and logs on a separate drive that's mirrored..? Oh and if anyone has links to this info let me know also.

Thx!

View 4 Replies View Related

Recommended Owned Of A DataBase

Jan 18, 2002

Hi,
What are current thoughts about who should own a Database?
I see 3 possibilities:
1. The DOMAINAdministrator (person wo starts up the Server at Bootup)
2. 'sa', or
3. a person/user closely tied to the database.

reasons for each?

Thanks for your opinions.
MichaelG

View 1 Replies View Related

Recommended Books For SQL 2000?

Jul 20, 2001

I have a couple of years of light experience with SQL server. I'd like to start studying to take the SQL 2000 exams. I have a good test environment set up and I'm reading through the Books Online. Can anyone recommend a book or books that might be helpful for me? My end goal here is to pass the test in the near future, but I want to really learn SQL rather than just learn to pass the test.

Thanks,

Allie

View 1 Replies View Related

Recommended OS For Sql Server 2000

Nov 5, 2004

i was pondering getting a MCDBA certification. i want to learn everything about the OS i'd use, so i just wanted to get some feedback on whether to go with NT or server 2003, etc. and anyone here recommend even getting or not bothering with the certification?

View 2 Replies View Related

Recommended Replication Type

Jul 27, 2007

We are replicating data from server1 to server2. We expect the connection between servers to be reliable, but we can not always guarantee uptime on both ends. We do not need real-time data access on server2. What type of replication would be best? The downside we see to snapshot is that the data will be growing over time and that means the amount replicated will continue to grow. Can we setup transaction replication and then schedule the updates so it only replicates transactions since the last update? Does this present any problems if the connection is lost at any time between the servers? At this time, we will not be making any changes to the data on server2 so it does not need to be updated on server1.

View 7 Replies View Related

Sa Password Recommended For End User?

Aug 12, 2007

Hi,

I have a database app that deploys with sql 2005 express to each end-user. I would like to install sql 2005 express using Windows Authentication only. In this case, should I bother to set an sa password? And if I do set the sa password, how would I go about making sure that the sa password is different for every installation of sql express? Would it be recommended to save every end-user's sa password (possibly tens of thousands of passwords) just in case sql maintenance needs to be done on their computer? Any help would be greatly appreciated. Thanks!

View 6 Replies View Related

Why Nested Views Are Not Recommended?

Jul 23, 2005

I'm reading a book 'Professional SQL Server 2000 Programming' by RobertVieirathere is a recommendation: "stay away from building views based onviews"Why? What's so wrong with nested views?

View 2 Replies View Related

Recommended Oracle Provider

May 31, 2007

I have been using the Microsoft Oracle Provider (MSDAORA) up until I needed to work with CLOB data types in Oracle. As much as I hate to switch providers at this phase in the project, I can't use MSDAORA due to the CLOB limitation.



So, what other providers are available?



I know that there is a native Oracle provider (OraOLEDB.Oracle.1) that is supported in SSIS. Does anyone have any comments on this?



Are there other options for Oracle?



Any comments, feedback, etc appreciated.



Thanks,



Rick

View 3 Replies View Related

Recommended SQL-server Book?

Feb 19, 2008

Hi,

Could anyone recommend a good book on the SQL-Server, please? I need to understand how to retrieve data with select statements and commands. It is urgent!

TIA

View 1 Replies View Related

Recommended Way To Install Database Driven App.

Dec 19, 2003

I was wondering what everyones preferred way to install a database in an automated fashion is.. IE:

You have a webapp. It sdriven by SQL Server. You need to prompt the user for a server, username, password, and database. Once you have those, you execute thge scripts against the DB.

I've been using osql.exe. but heres the situation. The installer may be run from a system, which does not have the sql server client tools installed. Which will be a problem.

So, given the situation that the machine the application is being installed on, does not have the client tools installed. How would YOU execute the provided SQL script against a remote server.

View 4 Replies View Related

Recommended Stretagy For Bi-Directional SQL DB Synchronization

Jul 23, 2005

Hi,Our company is an independent Voice applications solution provider withnumber clients using our suite. We have a CT application suite which isrunning with Application Server and SQL Server 7 / 2000 as DB Enginesat the back end.The SQL server has two databases configured:Logging Database - Massive updates every second, the data growsrapidly,Configuration Database - Generally small-sized and updatedoccasionally.Now we want to have the reslience implemented on the server. We have tosynchronize the two databases 'real-timely' and in 'efficient'manner, so that if Primary server or its Databases gets unavailable,the users are seamlessly switched over to the Secondry server that willhave its own set of data updated and well synchronized.Typically, it can be explained as follows:1. We will have 2 database servers A - Primary (acting as publisher)and B - Secondary (acting as subscriber). Our application will beinitially connected to A.2. When A becomes unavailable (for whatever reason), the applicationwill fail-over to B.3. All the users will be switched to server B and the updates are beingdone accordingly without being replicated on Server A temporarily.4. When A is back on-line, A needs to be brought up-to-date with Bautomatically (In other words, I shouldn't have to manually export allthe data from B to A ).Our requirements are:- The system should support Bi-directional Synchronizationbetween both the servers for their set of databases (the logging andconfiguration).- There will be constant and heavy activity in LoggingDatabase, thus if one server gets down the data should be logged andmaintained as it is on second server and on fail-back no data-lossshould occur with minimum latency time.- There could be a scenario when a server fails-over for aweek's time, there will be constant logging each second! Once itfails-back the system should rapidly synchronize the data withoutnoticeable delay among the two server database sets.- The system should also work fine if certain amount ofrecords are purged over a time period.Our concern is, observing the above scenario, how any of your SQLserver replication strategy can help us achieve the requirements.ThanksJohn

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved