Monday, December 27, 2021

Using Xcode to Develop a RDBMS

Ever since Apple stopped developing WebObjects, I haven't found a lightweight replacement for graphically designing relational databases like I used to do with EOModeler. Specifically, I wanted a graphical way to create a database by simply clicking and dragging between tables to join them as I demoed at WWDC in 2001.

RDBMS Design from Scratch

Earlier this year, I began a new software project, from scratch, that required a modest size relation database with about two dozen tables. I was surprised to discover that there was no simple RDBMS tool available, today, that could do what EOModeler did back in the mid-1990s.

After putting some thought into the problem, I realized that EOModeler and EOs (Enterprise Objects) were repurposed into Xcode's Core Data framework and renamed Managed Objects. Xcode's xcdatamodeld is nearly an identical implementation of EOModeler tied to a SQLite database. (SQLite is a lightweight RDBMS designed to be embedded in end-user applications instead of the traditional client-server architecture.)

Once I made the connection between EOModeler and Xcode, I reasoned that it might work very nicely for graphically designing the entity relationship model along with the SQL to created the schema. It turns out that I was right and it worked nicely. Here's how I did it...

1. I created an Xcode project that used Core Data.

2. I designed my database schema, graphically, in XCode by dragging between entities to create one-to-many, one-to-one, and many-to-many joins. (Note: Every time I was about to create a many-to-many join, I gave that relationship a long, hard look to make sure I was modeling it properly.)

3. Each time I built my Xcode project (which only contained the database model, no code needed), a new SQLite database was created in ~/Library/Containers/Project Name/Data/Library/Application Support/Project Name. In this folder are typically three files: the SQLite database (.sqlite), the write-ahead log (.sqlite-wal), and a temporary file for shared memory access (sqlite-shm).

4. I downloaded and installed DB Browser for SQLite to access the SQLite database that Xcode created. From there, I exported the database as a SQL file which was then used to create the same database schema in a Postgres database running on Amazon's RDS.

The only gotcha I encountered with Xcode was that sometimes, when I made changes to the database schema that conflicted with a previous database version, I'd have to delete the target folder in Step 3, above, so Xcode would recreate the database from scratch.

It's hard to beat Xcode's ease of use for RDBMS design, even though that's not its primary intent. Please let me know if you're aware of a database client that allows the simple graphical design that EOModeler used to have.

Saturday, December 25, 2021

Adventures in Absinthe

Absinthe fountain
In 1912, absinthe was banned in the U.S., for about a century, due to the misperception that it was poisonous or caused hallucinations. Now, much like the old fashioned, absinthe has regained popularity in recent years and the experience is worth the effort.

Absinthe is a rare drink in that it's not mixed by a bartender. Instead, it's prepared by the consumer, at their table, through a ritual known as louching where cold water is dripped over a sugar cube into a glass with absinthe. High end absinthe is typically more than 130 proof, so adding three to five parts water enhances the flavor while turning it from a deep green to a cloudy green that almost seems to glow.

Absinthe spoons

Absinthe Ritual

Louching begins with pouring about an ounce of absinthe into an absinthe glass. These glasses usually have a reservoir, or marking, on the bottom to make measuring the proper amount simple. An absinthe spoon is placed on the top of the glass with a sugar cube. The absinthe spoon typically looks like a cake cutter or pie serving knife with decorative slits. Cold water is then dripped onto the sugar which passes through the spoon and into the glass. The sugar water and absinthe emulsify as they mix in the glass giving it a distinctive cloudy, green look with a flavor similar to anisette, sambuca, or ouzo. The absinthe spoon has a point which makes it easy to stir any undissolved sugar in the glass' reservoir. That's the entire ritual – now drink up.

Louching
PSA: Never light absinthe or the sugar cube on fire. That's the equivalent of chugging a shot of top shelf, premium tequila with a lick of salt and bite of lemon. A couple of movies, in recent times, showed absinthe being lit and it caught on faster than eating Tide Pods.

Friday, December 10, 2021

Thoughts on Non-fungible Tokens

 I am not a fan of NFTs – at least not yet.

When we buy physical things, we typically have complete control over the item such as a book, cup, or car. It becomes less clear when we buy things like stock or real estate.

After an IPO, when you buy a publicly traded stock, the money you pay (invest) never actually goes to the company. Rather, the money simply goes to the person you bought the stock from. But you do get a say as a shareholder since you are a partial owner of the company.

Another way to think about NFTs is similar to a property deed. You can purchase property (land), outright, without a mortgage. But you can't move it just like Jack's first tweet can't be moved. And, even though you physically own the land you bought, you don't really own it. Stop paying your taxes and then see who owns the land.

Perhaps the best way to think of NFTs is as proof of intellectual property ownership.

So, while I'm not yet a big believer in the future of NFTs, I understand that they could become a deed for digital property... if they're widely adopted. Perhaps the future of NFTs, as digital property, will require a tax to be paid to keep the servers running – just like I pay property taxes to keep the streetlights lit and the roads maintained.