3

Normal Forms: Are They Actually Used?

by Alexandru Lungu 4. September 2010 14:26

 

I’ve been designing databases for more than half my life. And I never thought about normal forms. Actually I’ve heard about normal forms in my 2nd year in college; and I was so surprised that someone actually wasted his time writing about something so obvious. And because I had to learn them I took a little time to look deep into them. A few hours later I reached a conclusion (And I remember the exact words I told to a colleague): A useless set of rules that make me design a database 20 times slower than I normally do. Of course, I was ending up with identical design in both situations.

But, during times, I’ve seen a lot of bad database design; and if asked why it is bad I found to be easier to send the asker to read about the normal forms than to try to explain myself. 

The other days I saw a teacher with more than 30 years teaching experience looking at a small database, taking every table, column, checking dependencies to see if it is in the 3rd form. It took him about 10 minutes to reach my 30 seconds conclusion.

So, why I don’t think “normal forms”? I think that the way I learned programming and databases influences the way I reason.

I began my programming journey with Pascal in 9th grade. Very soon advanced to OOP and I also started creating application that were solving real life problems and of course get to wonder how to store data. I had objects and looking for a way to store them with minimum redundancy.  And I used what Pascal knew - sequential files based on which I created some sort of primitive databases. With Main Key,  Field Key, Link Key with the equivalent of Primary Key, Index, Foreign Key. That’s because I had absolutely no idea about the existence of databases so I had to create my own notions. Keep in mind that I was living in a small city where no computer science book could be found; we had no internet; half of the school year we had no teacher because no computer science teacher could be found; in the end we got an engineer that learned 25 years ago something with punch-cards and didn’t work in the same domain since. Therefore, the teacher was learning at the same time with us. (and the rest of the class were all pupils.) This happens when you’re born in a god forgotten city in a god forgotten country. But our lab had some i386 laptops donated by a US company that didn’t need them anymore as they bought the new i486.

About a year later a colleague came with a treasure: FoxPro and a few month later I went to Bucharest (yes, that’s the capital) where I spent all the money (saved in about a year) on computer science books (actually after looking in more than a dozen bookstores I found a book on FoxPro.

Soon I mastered the FoxPro and this got me a job during high school.

So, how do I conceive my tables? Well, I think it all has to do with objects; as in high school I start thinking of objects and then transform them into tables. Simple; effective; obvious; natural way (for me).

Do you use normal forms?

Tags:

Miscellaneous

0

The Gold Plating

by Alexandru Lungu 23. August 2010 18:47

 

I've seen a lot of gold plating lately; and both kinds: programmer and specification. I did programmer gold plating long time ago, but all ended when I became in charge of managing projects and close deadlines made me stop any gold plating attempts. 

But the latest experience with this made me realize who does and who doesn't do it.

People that don't gold plate are the ones that do the job exclusively for the money. They don't want to work more that is minimum necessary, which is a very good thing in trying to meet the deadline.

Gold plating is done by the people that are very passionate about their job; and more often by young people. And I think this is available not only for the software domain. 

Thus I realized that while specification gold plating shouldn't be allowed at all, a little programmer gold plating should be allowed - because otherwise you'll break the enthusiasm and joy of the passionate programmer for which the work itself is a reward.

Tags:

Project Management

2

EntitySqlException was unhandled…

by Alexandru Lungu 10. August 2010 07:38

 

'Name' could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly. Near simple identifier, line 6, column 1.

I've got the above error while running the following code (actually the code was a more complex but I reduced it to essentials):

DbTestEntities db = new DbTestEntities();
var query = db.People.Where("Name = 'John'");
Console.WriteLine(query.Count());

(I think it is obvious that I have a test db with a Person table)

There seems to be something wrong with the 'Name' from my expression, but what exactly could it be on such a simple expression? The Name column does exist.

I googled the error and found some people that encountered this error but in different circumstances which didn't get me the solution but put me on the right track: a guy had the same problem with an OrderBy("Column") so it become clear to me that using just the column name isn't going to work.

Next I looked at the sql expression that gets generated and found what was wrong:

Console.WriteLine(query.CommandText);

Yes, that "it" alias was the problem so the following code works:

DbTestEntities db = new DbTestEntities();
var query = db.People.Where("it.Name = 'John'");
Console.WriteLine(query.Count());

Next the question: can it be always used as it.Column?
After running a few tests the answer is positive.

Can it be changed to other alias name?
Actually it can - looking to ObjectSet's properties I quickly identified the property: Name (dooh! ). 

So now I can do this:

db.People.Name = "People";
var query = db.People.Where("People.Name = 'John'");
Console.WriteLine(query.CommandText);

And no, it doesn't work to set the Name to empty string (or null). 

I remembered vaguely that long time ago I read a post about using string c# code instead of string sql code.  A quick search on my favorite blogs found this article of Scott Guthrie - Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library) in which he points to an example on how to do that.

IQueryable was extended for this.  I’ve tried and worked as expected:

var query = db.People.AsQueryable().Where("Name == \"John\"");
//or I can use parameters
var query2 = db.People.AsQueryable().Where("Name == @0", "John");

Tags: , ,

Programming

5

The Pragmatic Programmer

by Alexandru Lungu 26. July 2010 22:24

 

During the SqlServer 2008 R2 launch in Romania (March 10th 2010 - Howard Johnson’s Hotel Bucharest) I've met with an old colleague I worked a few years ago at Totalsoft, Teodor Blidarus. He held a presentation during which he asked the audience "who read the The Pragmatic Programmer" and mentioned that the book changed his life.

Only one people raised his hand from about 100 people. At that time I never heard about the book, but this guy was one of the best professionals I worked with so I was intrigued. I looked for the book and red it. The book is indeed extremely good, but it would've been really useful for me when I was 14 and at the start of my journey. There was nothing from that book that now I don't already know.

Most of the time, while reading it, I was remembering being in situations, or reaching conclusions like the ones presented in the book. Of course it would've been better to learn all of those things from the book than from real life (actually some of them I learn it from other books, some were obvious, but still remain enough that I learned the hard way).

Therefore I've decided to promote this book on my blog.

So, if you feel like a journeyman (or don't feel like Master), take a look at this book. Or at least take a look at their tips.

Tags:

Miscellaneous

3

R.I.P. VistaDb?

by Alexandru Lungu 11. July 2010 13:39

 

VistaDb is closing their office as its founder states here.

I was one of the many that wasn’t seduced by VistaDb. I did take it into consideration along SqlCe and SQLite for an application. Though I was impressed the most by SQLite I end up using SqlCE because of better date/time manipulation and it was integrated in Visual Studio; also because I anticipated a better implication of Microsoft in the forthcoming releases as it will be a necessary piece in the battle to occupy the mobile devices software.

At that time VistaDB had the worst stats in benchmarks, wasn’t free like the others, and it was at its infancy. So it had no chance in choosing it.

Looking now at their features (if they really work as advertised), it is an impressive piece of software that probably took a lot of development time – mostly high quality development time (building something like VistaDB this is not the same thing as dragging and dropping a few controls on the form and binding them to a data source). 

And since it is closing down it can be purchased for almost nothing.

Therefore I think that there will be a buyer. And VistaDB will not Rest In Peace; at least not so soon.

Tags: ,

News

1

Hello World, Again!

by Alexandru Lungu 5. July 2010 08:56

After a long time, I've decided to start blogging again... and of course this post being the first it was extremely hard to conceive... next ones will probably be much easier…Laughing

Tags:

Miscellaneous

Powered by BlogEngine.NET 2.0.0.36
Original Design by Laptop Geek, Adapted by onesoft