Dynamic columns in MariaDB

Add columns to a table on the fly without altering its schema.

MariaDB and similar SQL database systems allow for a variety of data types that may be used for storing data in columns within tables. When creating or altering a table’s schema, it’s good to know what to expect, to know what kind of data will be stored in each column. If you know that a column will contain numbers, use a numeric data type like INT, not VARCHAR. It’s best to use the appropriate data type for a column. Generally, you’ll have better control of the data and possibly better performance.

But sometimes you can’t predict what type of data might be entered into a column. For such a situation, you might use VARCHAR set to 255 characters wide, or maybe TEXT if plenty of data might be entered. This is a very cool and fairly new alternative: you could create a table in which you would add columns on the fly, but without altering the table’s schema. That may sound absurd, but it’s possible to do this in MariaDB with dynamic columns.

Dynamic columns are basically columns within a column. If you know programming well, they’re like a hash within an array. That may sound confusing, but it will make more sense when you see it in action. To illustrate this, I’ll pull some ideas from my new book, Learning MySQL and MariaDB (O’Reilly 2015). All of the examples in my book and this article are based on a database for bird-watchers.

Read more…

Comments: 5

What you need to consider before moving to management

Assessing the many paths to a management role.

You’ve been at your company a while, maybe as little as a couple of years, maybe substantially more, and the idea of moving into management has crossed your mind. The idea can occur for any number of reasons. Maybe you found out that there’s an opening, either internally or at a different company. Maybe someone from management has asked if you’re interested. Maybe you’ve been in your current position for a while, and it’s not as challenging as it used to be. Maybe you’ve been unimpressed with the management at your company, and you think you can do a better job. No matter what the situation, you’re suddenly faced with the idea of becoming a manager. Is jumping to management a leap you’re ready to make, and what are the alternatives if you don’t?
Read more…

Comments: 5

Teaching kids how to code with Minecraft

Maintaining a focus on fun and interactivity keeps students engaged and enthused while learning Java.

I am jealous of kids these days. The sheer breadth and depth of technology and software at their disposal is staggering, everything from Raspberry Pi, Arduino, and Scratch to Minecraft, Python, and iOS app development. What’s even more profound to me is how fluent they are in using and interacting with these technologies. And yet during this process of assimilation, they are mastering fundamental mathematical concepts, like trigonometry, by figuring out how to shoot an arrow in Minecraft, as opposed to the classical way of learning the formulas. Or in learning how to program in Python, they are creating a game of Tic-Tac-Toe. Or in understanding basic circuits, they are building a traffic light using Arduino or Squishy Circuits.

I consider myself extremely fortunate to be involved with Devoxx4Kids, a Not-for-Profit, 501(c)(3) registered organization in the U.S., whose goal is to deliver Science Technology Engineering Mathematics (STEM) workshops to kids at an early age around the world. We delivered over 40 workshops in the U.S. alone last year on topics ranging from Python, Scratch, and Minecraft modding to NAO robots, Raspberry Pi, Arduino, and Little Circuits. Globally, we’ve delivered over 350 workshops and connected with approximately 5,000 students, with over 30% girls. Attendees from these workshops often leave with unique and inspirational stories to share. Read more…

Comments: 5

5 reasons why Python is a popular teaching language

Python's simplicity makes it accessible to learners and teachers alike.

Download a free copy of Python in Education. Editor’s note: this is an excerpt from Python in Education, a free report written by Nicholas Tollervey.

I am going to answer a very simple question: which features of the Python language itself make it appropriate for education? This will involve learning a little Python and reading some code. But don’t worry if you’re not a coder! This chapter will hopefully open your eyes to how easy it is to learn Python (and thus, why it is such a popular choice as a teaching language).

Code readability

When I write a to-do list on a piece of paper, it looks something like this:

Fix broken gutter
Mow the lawn  

This is an obvious list of items. If I wanted to break down my to-do list a bit further, I might write something like this:

Fix broken gutter:
    Borrow ladder from next door
    Find hammer and nails
    Return ladder!
Mow the lawn:
    Check lawn around pond for frogs
    Check mower fuel level 

Intuitively, we understand that the main tasks are broken down into sub-tasks that are indented underneath the main task to which they relate. This makes it easy to see, at a glance, how the tasks relate to each other.

Read more…

Comments: 5

Open source won, so what’s next?

What to expect at OSCON 2015.

OSCON 2014 show floor

Twenty years ago, open source was a cause. Ten years ago, it was the underdog. Today, it sits upon the Iron Throne ruling all it surveys. Software engineers now use open source frameworks, languages, and tools in almost all projects.

When I was putting together the program for OSCON with the other program chairs, it occurred to me that by covering “just” open source, we weren’t really leaving out all that much of the software landscape. It seems open source has indeed won, but let’s not gloat; let’s make things even better. Open source has made many great changes to software possible, but the spirit of the founding community goes well beyond code. Read more…

Comments: 5

Translating your Objective-C project to Swift

A step-by-step approach to using Swift with Objective-C.


If you’ve got an existing app written in Objective-C, migrating it into Swift is an excellent exercise for learning Swift, experimenting with Swift, and deciding whether to adopt Swift on a full-time basis. I’ve performed this migration with several real apps, so here are some tips culled from my actual experience.

Hybrid targets

You’re surely not going to translate all your code into Swift at once; you’re much more likely to translate one class at a time. As soon as you add a Swift file to your Objective-C app target, you’ve got a hybrid target: some classes are written in Swift, while other other classes are written in Objective-C. Thus, declarations in each language will need to be visible to the other language. Before you start, it’s a good idea to understand how this visibility works.

Recall that an Objective-C class declaration is conventionally spread over two files: a header file (.h) containing the @interface section, and a code file (.m) containing the @implementation section. If a .m file needs to know about a class, it imports the corresponding .h file.

Visibility of Swift and Objective-C to one another depends upon this convention: it works through .h files. There are two directions of visibility, and they must be considered separately.

Read more…

Comments: 5