SQLServerCentral - www.sqlservercentral.com

A community of more than 1,600,000 database professionals and growing

Featured Contents

The Voice of the DBA

Singular or Plural

There are all sorts of interesting debates that developers will have about programming. One of those I've written about in the past is Spaces v Tabs. There's a lot of discussion about that one, and certainly no share of strong opinions. I'm sure there are plenty of other development paradigms and habits that will create debate, arguments, and perhaps strain some working relationships.

While I'm not looking to upset anyone, I ran across a discussion recently and thought this would make an interesting debate. If you've got an opinion, please share how and why you might choose to follow your convention. Examples are helpful and may enhance the reasons why you go choose to build systems one way or the other.

If you examine any sample databases out there, you will run across tables named like this: Customers, Orders, Cities, etc. You might also find Product, Person, Address as well. If you are paying attention, you might notice that my examples are both singular and plural in their form. There are no shortage of debates on the topic, but I'm wondering what many of you think.

I've tended to build tables with plural nouns in the past, but I think that's because the first few people that taught me did that. As I've read more and listened to others explain their design decisions, I've embraced singular names. After all, the entity being modeled is often a single instance of a type. A Person or a CreditCard, not a series of them, though we could certainly argue the table is a set of people, so use that.

Ultimately I'm not sure that it matters much in any particular application. We certainly have databases that using each convention, and probably a few that use both inside the same schema. I think choosing an entity name that is easy to understand is important, and maybe the idea of singular or plural names matters less. After all, as long as you're not naming tables F42 and H1492, everyone will get used to the convention.

Steve Jones from SQLServerCentral.com

Join the debate, and respond to today's editorial on the forums


The Voice of the DBA Podcast

Listen to the MP3 Audio (3.5 MB) podcast or subscribe to the feed at iTunes and Libsyn. feed

The Voice of the DBA podcast features music by Everyday Jones. No relation, but I stumbled on to them and really like the music.

ADVERTISEMENT
Redgate Hub

Register now for SQL in the City Streamed

Redgate’s popular SQL in the City Streamed virtual event takes place again this December. Wherever you are, tune in on Wednesday December 13 to watch some of the best-known speakers from the database world present the latest technologies and tools from Redgate. Register free now

SQL Clone

SQL Clone: Now supporting databases up to 64TB

Create copies of production databases and SQL backups in seconds and save up to 99% of disk space using SQL Clone. Redgate’s new tool removes much of the time and resource needed to create and manage database copies, allowing teams to work on local environments to develop, test and diagnose issues faster. Try it free

Featured Contents

 

Bones of SQL – Grouping By User-Defined Calendar Periods

Bob Hovious from SQLServerCentral.com

Although it is common to group by periods such as Week, Month, or Quarter, sometimes alternative periods are needed. This simple technique lets you split a year into periods with any number of days. More »


 

How Much Data Has Changed Since Your Last Full Backup

Additional Articles from Database Journal

Have you ever wanted to know how many pages in your database have changed since the last full backup? If so, then you will be glad to hear that the SQL Server 2017 version of the DMV, sys.dm_db_file_spavce_usage, has a new column named modified_extent_page_count, which shows the number of pages that have changed since the last full backup. More »


 

Free virtual event: SQL in the City Streamed

Technical sessions will dive into the latest Microsoft SQL Server releases, and cover topical issues such as data compliance, protection & privacy. More »


 

From the SQLServerCentral Blogs - Design Concepts To Help You Create Better Power BI Reports

meaganl from SQLServerCentral Blogs

I have decided to write a series of blog posts about visual design concepts that can have a big impact... More »


 

From the SQLServerCentral Blogs - An Introduction to Azure SQL Databases

David Postlethwaite from SQLServerCentral Blogs

This David's SQL Server Saturday talk titled an introduction to Azure SQL Databases It does pretty much what is says on... More »

Question of the Day

Today's Question (by Steve Jones):

I want to build an advent calendar for Christmas that will count down the days to Christmas, while showing the current date. Which one of these works the best?

 -- Query 1 WITH myTally (n) AS ( SELECT TOP 25 n = ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM ( VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10)) AS a (n) CROSS JOIN ( VALUES (1),(2),(3)) AS b (n) ) SELECT Today = DATEADD(DAY, 25 - n, '2017-12-25'), DaysLeft = 25 - n FROM myTally; -- Query 2 GO WITH myTally (n) AS ( SELECT TOP 25 n = ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM ( VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10)) AS a (n) CROSS JOIN ( VALUES (1),(2),(3)) AS b (n) ) SELECT Today = DATEADD(DAY, n, '2017-12-25'), DaysLeft = 25 - n FROM myTally; GO -- Query 3 WITH myTally (n) AS ( SELECT TOP 25 n = ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM ( VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10)) AS a (n) CROSS JOIN ( VALUES (1),(2),(3)) AS b (n) ) SELECT Today = DATEADD(DAY, n - 25, '2017-12-25'), DaysLeft = 25 - n FROM myTally; GO -- Query 4 WITH myTally (n) AS ( SELECT TOP 25 n = ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM ( VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10)) AS a (n) CROSS JOIN ( VALUES (1),(2),(3)) AS b (n) ) SELECT Today = DATEADD(DAY, n - 25, '2017-12-25'), DaysLeft = n FROM myTally; GO 

Think you know the answer? Click here, and find out if you are right.


We keep track of your score to give you bragging rights against your peers.
This question is worth 2 points in this category: humor.

We'd love to give you credit for your own question and answer.
To submit a QOTD, simply log in to the Contribution Center.

ADVERTISEMENT

Pro Power BI Desktop

This book shows how to deliver eye-catching Business Intelligence with Microsoft Power BI Desktop. You can now take data from virtually any source and use it to produce stunning dashboards and compelling reports that will seize your audience’s attention. Slice and dice the data with remarkable ease then add metrics and KPIs to project the insights that create your competitive advantage.

Yesterday's Question of the Day

Yesterday's Question (by Evgeny Garaev):

What ts the result of this script executed on SQL Server 2016?

Answer: Sucess, two rows returned

Explanation:

Table variables do not support transactions.

Ref: Rollback Transactions - https://docs.microsoft.com/en-us/sql/t-sql/language-elements/rollback-transaction-transact-sql


» Discuss this question and answer on the forums

Database Pros Who Need Your Help

Here's a few of the new posts today on the forums. To see more, visit the forums.

SQL Server 2017 : SQL Server 2017 - Administration

SQL Restore takes long time - how do I clear committed transactions from log ? - Hi everyone, There is so many blog posts and articles out there about this case and I have been reading, but...


SQL Server 2017 : SQL Server 2017 - Development

DISTINCT FOR ONE COLUMN ONLY - Guys,  how do i make the following only bring back one value for each REGNO? As you can see some...

INDEX MATCH IN SQL.... IS IT POSSIBLE?? - Mail – craig.jenkins@monmotors.com                                             &


SQL Server 2016 : SQL Server 2016 - Administration

Agent Job fails on "sa" account login - I have a couple of SQL Server Agent jobs configured to run as "sa" However, they fail with the error "Description:...


SQL Server 2016 : SQL Server 2016 - Development and T-SQL

Scalar functions and performance drop off - Hi, I have tried a few things now and I am not really getting anywhere. I have a database which is...

returning numeric value - Hello comunity I need help for returning numeric values from dynamic sql. My script is    DECLARE @BD VARCHAR(40)     DECLARE @myobrano INT          SET @BD...

Question about the GO statement - Hi, I know that using "GO 9" for example will execute a batch of T-SQL commands 9 times. E.g. /* this block...

Sorting after records deleted - CREATE


SQL Server 2014 : Administration - SQL Server 2014

Resource utilization difference - Hi Experts, IT team gave us memory utilization report for each servers. In the list the memory utilization of SQL Server...

Bulk insert into table from csv - Hi, i have table in CSV: As you can see there are a lot of columns.  My source table data types fields are:


SQL Server 2014 : Development - SQL Server 2014

A different end table by parameter - Hi guys, I have loads of stored procs that gather data but need an option to be inserted into different tables. Basically...


SQL Server 2012 : SQL Server 2012 - T-SQL

Index question - Hi All, Need to identify repeated/duplicate indexes. Sample table : create table test_tbl (id int not null primary key, userid int, deptid int,...

Split out data from single field that is encoded with new lines - I have a table with one field that merges all notes entered from an application into a single varchar(MAX) field. ...

Query working differently on different servers - Hi - I've got a development server where my T-SQL code is working fine, but when I port it to my...

No of Months between two dates in YYYYMM format - I am looking to calculate no of months between two dates which are in YYYYMM format. Like no of months between...


SQL Server 2008 : SQL Server 2008 - General

Remove duplicate values - Hi Experts, In the below table records are grouped by ID column. If the count for ID is greater than 1 then...


SQL Server 2008 : SQL Server Newbies

find out what transaction caused the log file to become full yesterday or day before yesterday - Good Morning Experts,An application job has been failing repeatedly with below error from last 3 days. Is there a way...

Log file R drive- What is consuming it - Good Morning Experts. We have a SQL Server instance. All the user databases log files are on R drive. We have...


SQL Server 2008 : SQL Server 2008 Administration

SQL Server Restart - Reason - Hi there We had sql server restarted unexpectedly and i am trying to find the reason. In my experience (I am...


SQL Server 2005 : Administering

info using sysarticles and syspublications - Is there a way to get the below information by joining sysarticles and syspublications Get Transactional replication details (publisher name, Publication,...

This email has been sent to newsletter@newslettercollector.com. To be removed from this list, please click here.
If you have any problems leaving the list, please contact the webmaster@sqlservercentral.com.
This newsletter was sent to you because you signed up at SQLServerCentral.com.
Feel free to forward this to any colleagues that you think might be interested.
If you have received this email from a colleague, you can register to receive it here.
This transmission is ©2017 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
Contact: webmaster@sqlservercentral.com