Learning Mandarin: Loan words can be tricky

In English, we often "borrow" words from other languages. The Chinese call these "loan words". For example, we might talk about a feeling of Déjà vu. Now we'll often write it without the original accents on the "e" and the "a" but we'll happily just use the French word in conversation.

Ironically, the French tend to do the opposite. They keep inventing words to fill in the gaps in their language. I've heard that this is causing them great difficulty in technical words and that their language academy is a long, long way behind in creating those words.

In Mandarin, a similar thing happens. And it's one of the things that confuses me when I'm reading Mandarin. Let's look at an example:

夏洛克  (Xià luòkè)

I normally read the first character as being related to summer. The second character is often a surname. It's also an old name of several rivers in Henan, Shaanxi, Sichuan, and Anhui. The third character is typically used for the word gram.

So when I read this, I'm thinking "summer, some name, gram". And it's only after a while I pronounce the whole thing and realize that it makes no sense at all as written. It's all about how it sounds. In this case, it was meant to be Sherlock (as in Sherlock Holmes).

I find names quite tricky to recognize to start with, but these transliterated words are especially tricky. But they are used extensively. It's not always names though. Here's another:

巧克力  (Qiǎokèlì)

Again when reading this, the words are like "skillful, gram, force or energy". But the word is chocolate.

And another:

酒吧  (Jiǔbā)

In this case, the first word is Chinese for alcohol, but the second word means bar in English.

So when reading Mandarin, and the words seem to make no sense at all together, one of the things I'm learning to do, is to step back and pronounce them, just in case the meaning of the characters isn't relevant, and only how they sound matters.

Learning Mandarin

I'll write more soon on the best methods for learning. If you want to get a taste for it in the meantime though, my current favorite is Tutor Ming. If you decide to try it, click here and it's a bit cheaper for you, and for me.

Using the classic editor in WordPress 5.0

Well today WordPress on my blog site went up to version 5.0. I knew a new editor (Gutenberg) had been coming to replace the classic editor but I hadn't had time to try it. So when it did the upgrade, I happily let it go and install the new editor.

Then I tried to write a post.

Oh my goodness, that was just a horrid, horrid experience. I can see what they've tried to do but it literally took me about five times longer than normal to write a single post.

I actually like change. In fact I tend to thrive on it. I can even imagine how this might help build certain types of pages better. But for someone writing blog posts with a heading, a bunch of text and images, etc. I can't imagine what they were thinking.

Each paragraph has become a "block" and I kept finding the pop-up block headers getting in the way the whole time I'm editing. Perhaps the people who love this don't touch type, or they always write pages in order and don't jump around but I can't tell you how annoying it was.

Worse, it kept deciding that I needed new lines when I didn't ask for them. I'd put the cursor beside an open bracket on a line, click Control-V, and then find it had inserted a newline before the pasted data. I was endlessly editing out things that it pushed in.

And so on and so on.

I kept looking for the "how to get rid of the new editor" posts but the best option now seems to be to use the Classic Editor plugin. Let's just say that's been a godsend. And given the number of installs it already has, I don't think I'm alone on this one.

Recommended !

Book Review: Will It Fly? by Pat Flynn

I'm a fan of Pat Flynn. If you haven't listened to his Smart Passive Income podcast, and you have any interest in being self-sufficient without "working for the man", Pat's podcast would be a good start. Pat has people ask him about ideas though and he's put his ideas on how to work out if an idea is worth pursuing in his book: Will It Fly? How to Test Your Next Business Idea So You Don't Waste Your Time and Money.

People often have what they think are great ideas but they don't know if they really are good ideas or not. The lousy situation is where they then invest a great deal of money building/creating something, only to watch it fail miserably in the market.

Pat's book is designed to help to avoid that.

Pat is a thought leader in this part of the market. And he's done very, very well from his work. Ironically, it all started because he lost his "real" job. In this book, he helps you through the steps of what to do before launching (or particularly before investing heavily) in your business idea.

Entrepreneurship is hard, but it can also be very rewarding. That's a scary concept for many. So often, people live from pay to pay, or have such heavy commitments, that they feel they really have few options.

I can't say that I miss doing a "normal" job and I can't imagine ever wanting to do one again, no matter what happens. I wish this book had been available decades ago. It would have saved me a lot of time and effort along the way.

Bottom line?

This book won't help you decide if you should be an entrepreneur. But if you've decided to do so, this book is great material for anyone looking to start a business, launch a product, or even change tack in their current business.

Greg's rating: 9 out of 10

Note: as an Amazon Associate I earn from qualifying purchases but whether or not I recommend a book is unrelated to this. One day it might just help cover some of my site costs. (But given the rate, that's not really likely anyway 🙂

Shortcut: Compare query plans in SQL Server Management Studio

One of the advantages of SQL Server Management Studio (SSMS) is that it can be used to analyze queries, not just to execute them.

There are two basic types of query plan: estimated execution plans, and actual execution plans.

For a typical query, I can obtain the estimated execution plan, by hitting Ctrl-L, choosing the option in the Query menu, or clicking on the toolbar icon:

Let's do this for the following query:

We get the following plan output:

Now we might look at this plan and wonder if we exerted control over how the joins were performed, if we'd improve things. Perhaps we'd heard that merge joins were more efficient and thought SQL Server should have used those.

Now we can change the query like this:

Notice I've added the word MERGE between INNER and JOIN in this query. But how do we know what SQL Server thinks? We can get another estimated query plan but what we really want is to compare them.

When we obtain an estimated plan for multiple queries at once, SSMS shows us a comparison of the two, by showing us the proportion of the overall query for each part. (Perhaps we shouldn't force that change 😊)

SDU Tools: List use of Deprecated Data Types in a SQL Server Database

I'm often reviewing existing databases and one of the first things I go looking for is the way they've used data types. In particular, I'm keen to know if they've used any deprecated data types (ie: ones that will/might be removed at some point).  In our free SDU Tools for developers and DBAs,  we added a procedure ListUseOfDeprecatedDataTypes to do just that, and to provide their details in a form that's easy to consume programmatically if you need that.

You can see how to execute it in the main image above. The procedure takes these parameters:

@DatabaseName sysname – This is the database to process
@SchemasToList nvarchar(max) – a comma-delimited list of schemas to include (ie: 'Sales,Purchasing') or the word 'ALL'
@TablesToList nvarchar(max)- a comma-delimited list of tables to include (ie: 'Customers,Orders') or the word 'ALL'
@ColumnsToList nvarchar(max) – a comma-delimited list of columns to include (ie: 'CustomerName,StreetAddress') or the word 'ALL'

One row is returned for each use of each deprecated data type.

The columns returned are SchemaName, TableName, ColumnName, DataType, and SuggestedReplacementType.

You can see it in action here:

To become an SDU Insider and to get our free tools and eBooks, please just visit here:

http://sdutools.sqldownunder.com

Opinion: Case sensitivity is a pox on computing

I've been in the IT industry a long, long time. One thing that I've never liked is case sensitivity in application development tools or in database languages.  And it's creeping into more and more places.

I know that will offend some people but hear me out.

I think we're stuck with case sensitivity in languages like C, C#, C++, Java, etc. because that was the easiest way to implement those languages in the first place. As soon as you decide that a language is case insensitive, you also have to decide the internal collation rules. For example, is the letter A the same as the letter a ? But then what about the letter á ?

I get that it's a hassle but humans just don't think in a case sensitive way, and that shouldn't be the basis of designing a language for humans to use. It might be computers that execute it but it's humans that write it, and more importantly, read it.

Now before I have people jump all over me, I'm not talking about case preservation.

It is important to me that if I write CustomerName or customerName, that when the system sends that value back to me, that it shows it the same way that I defined it. That's case preservation, not case sensitivity. I just shouldn't have to request objects or data in a specific case sensitive form. If it's a development tool, just automagically convert it to the defined case. If it's a database, just give me the data.

And I hear the C folk charging along in the background arguing that there's a common standard for backing variables (ie: someProperty) to have the same name as properties, with just a case change (ie: SomeProperty).

Sorry, but that was never a good idea either. There are other ways that we can solve that problem, and I've lost count of the number of times I've seen bugs in code where a property should have been accessed but a variable was accessed instead.

When you break it down to its essence, what case sensitivity does is allow me to have two objects in the same object scope, that differ only by the casing of their names.

You'll have a hard time convincing me that that was ever a good idea.

SQL: Should foreign keys be indexed in SQL Server?

If I create a primary key (let's say a CustomerID in a Customers table) in SQL Server, an index is automatically created to support that key. Primary keys must be unique and not null. SQL Server uses that index to ensure that the key is unique. Keep in mind that when I say "key", I'm referring to one or more columns, not necessarily just one.

The same happens for unique keys. Again, it makes it easy for SQL Server to ensure the uniqueness.

But if I create a foreign key (let's say a CustomerID in an Orders table), SQL Server doesn't create any index to support that. When I have the foreign key in place, and I perform an INSERT or UPDATE, it can use the primary key of the Customers table to check whether or not the customer exists.

Where the problems start

That's all well and good. But ask yourself: what's the chance that I need to come the other way across the relationship ie: find me the orders for a particular customer? At that point, you'd want an index to help your query.

DELETE statements can be even nastier. If I execute a command to just delete one customer, without any index in place, that's going to cause SQL Server to read the entire Orders table first. It has to make sure there are no orders for that customer. So a simple DELETE operation that should take no time at all, suddenly becomes a nasty mess that involves reading millions or billions of rows. I'd also end up with all sorts of locks involved.

An index on the foreign key would have avoided that.

The big question though is if SQL Server auto-created the index for you, would it be useful? For the DELETE operation, it most certainly would be, and for that reason alone, I'd like to see it there.

But what about the query? Well it's likely that if I was looking for all the orders for a customer, I'd want more than the OrderID. I'd probably want an OrderDate, a DueDate, a PurchaseOrderNumber, etc. And this is where the controversy starts. That auto-created index would be OK for this, as long as the query was highly selective. It would end up doing lookups to get the other columns once it found the orders.

But if the outcome wasn't highly selective, the index would be ignored. SQL Server would decide that the lookups would be too expensive.

What's needed

So what is needed? I'd need an index where the CustomerID was the first component of the index, and the other columns were either index key columns, or included columns. So perhaps an index like this:

CREATE INDEX FK_dbo_Orders_dbo_Customers
ON dbo.Orders (CustomerID, OrderDate)
INCLUDE (DueDate, PurchaseOrderNumber);

Importantly, that index would work for the DELETE operation as well.

Wish time

I believe that SQL Server would be overall better if it auto-created indexes to support foreign keys. I just see too many issues happen because they're missing.

Ideally, it would do that only unless it detected that there was another suitable index (best bet). Alternately, it could offer an I_KNOW_WHAT_I_AM_DOING clause when creating the foreign key.

OK, perhaps I'd settle for a clause like WITH NO_INDEX.

What's that smell?

When I'm reviewing databases, I do look for this. I consider a declared foreign key, where there is no index with the foreign key columns as its left-most components, to be a code smell.

If you want to check for these, our ListUnindexedForeignKeys procedure in our free developer and DBA toolkit (SDU Tools) offers a simple way to find out.

Learning Mandarin: East, West, Something, and Nothing

In Mandarin, the word for compass directions are:

East is  (Dōng)
West is 西 (Xī)
North is  (Běi)
South is  (Nán)

Curiously though, the Chinese don't say North, South, East, and West for compass directions like we do. Instead they say (Dōng), (Nán), 西 (Xī), (Běi) ie: they do them clockwise which is probably more sensible than us.

Awesome image by G Crescoli
Awesome image by G Crescoli

These directions are often combined with  (Biān) which roughly means side.

You'll hear 北边 (Běibian) as the north side (or sometimes more like locating something as being to the north of).  (Fāng) might also be used in a related way but mean more like in the direction of.  So 北方 (Běifāng) would be "in the direction of north" or perhaps "northward".

You'll often also hear them in relation to cities:

北京 (Běijīng)
南京 (Nánjīng)

The character  (Jīng) means something like the capital of a country or a region. So Běijīng is really like "northern capital" and Nánjīng was more like "southern capital".

And you'll hear them combined together, much the same way we say "northeast":

东北 (Dōngběi)

When they are combined like this though, East and West always come first.

But then the most curious combination of all is:

东西 (Dōngxī)

which you'd generally expect to mean East to West, and while it can have a meaning like that, it's generally used for "something".

我会买东西。(Wǒ huì mǎi dōngxī) or "I will buy something".

Not having it can also be used to define "nothing":

我没有东西。(Wǒ méiyǒu dōngxī)

is literally "I not have thing" would mean "I have nothing".

Learning Mandarin

I'll write more soon on the best methods for learning. If you want to get a taste for it in the meantime though, my current favorite is Tutor Ming. If you decide to try it, click here and it's a bit cheaper for you, and for me.

Book Review: The Missionary Position: Mother Teresa in Theory and Practice

When I was growing up, we were endlessly shown Mother Teresa (now known as Saint Teresa of Calcutta by Catholics) as an example of a person who had devoted their life to the service of others, and did so in appalling situations. I knew that the myth surrounding this woman was very different to the reality and I'm surprised that I hadn't previously read Christopher Hitchen's book: Book Review: The Missionary Position: Mother Teresa in Theory and Practice.

An excerpt from the first two reviews on Amazon sum up this book pretty well:

sterlingAg said: "You don't have to either love or hate Mother Theresa to enjoy this book, although it may be a tough read for the former. I've always believed that Christopher Hitchens' goal is not to bring your thinking in line with his; rather, it is to provoke your thought, your investigation and, maybe later, your evaluation. He does this masterfully here."

and

Jay Young said: "About 10 years ago, I hated Christopher Hitchens, particularly for his attacks on Mother Teresa. Of course, I was uncritically relying on Bill Donahue's Catholic League for my views on the subject. I was convinced that Hitchens was launching a malicious, hateful attack on a woman who did more good than he ever did. As you may have guessed, my views have changed since then. …  Hitchens, however, definitely has assembled an incisive case against the idolization of Mother Teresa. The evidence is hard to argue against, and Hitchens only asks that her reputation by judged by her actions, not the other way around."

To say that this would be a tough read for fans of Mother Teresa (or at least of the myth of Mother Teresa) is an understatement.

Hitchens provides a very sharp and strongly argued position for his opinions. She has been held in high regard for very questionable reasons, and with amazingly little positive evidence, and an unbelievable amount of (peculiarly discounted) negative evidence.

The details he provides of her financial dealings, and the depth of her relationships and engagements with very questionable people is beyond compelling and eye-opening.

Hitchens' book is a staggering indictment of the mythology that surrounds Mother Teresa. This is made more compelling by the time he spent with her, and his interviews with her. Remarks like the following provide a hint on her thinking:

"She assured me, that she wasn't working to alleviate poverty. She was working to expand the number of Catholics. She said: 'I'm not a social worker.'"

Bottom line: Hitchens will have raised the ire of many with this book, but no matter what your initial impressions or beliefs in her are, if you haven't read it, I suspect you aren't well-informed on the topic. Read it before you form an opinion of the book. Don't just believe the positive spin.

Greg's rating: 9 out of 10

Note: as an Amazon Associate I earn from qualifying purchases but whether or not I recommend a book is unrelated to this. One day it might just help cover some of my site costs. (But given the rate, that's not really likely anyway 🙂

Shortcut: Query and results in separate tab in SQL Server Management Studio

Another simple tip for today. In SQL Server Management Studio (SSMS), query results are normally shown at the bottom of the query window.

This can greatly reduce the screen real estate both for the query, and for viewing the results.

In Tools, Options, Query Results, SQL Server, Results to Grid, there is an option to Display results in a separate tab. This can be very useful and generally you will also want to choose the extra option to Switch to results tab after the query executes.

There is a similar (but separate) option for working with results to text rather than grid.

One further option on this dialog that's worth mentioning is the Include the query in the result set. I find that useful when working with text output, not so much with grid output.