I think it is a time to do something really crazy, write something which probably doesn’t give any value any of you instead of me, let’s write our own database from scratch! 😀 Until today I know quite good how databases work from a data management perspective. Especially Oracle allows you to study more of processes in data base, because of very good documentation and even direct access to raw data on
Language selection
Okie, if you already decided to start this journey with me then we have to answer ourselves to one question: which language is the best to create this project? My choice was simple, for me language for this project should be typed and quite fast. Until today I was able to programming in ABAP, Java, Python, R, and … I just want to know something new… In this ranking, I saw that there is a lot of languages faster than Java. Python is dynamically typed, building this project in R or ABAP will be too crazy for me, so maybe Swift? Pretty fast, typed language and with a possibility to run on any OS like Windows, Linux and of course Mac OS. The main disadvantage in my case is that I don’t ever use him before, so please forgive me, because in this project we will have for sure a lot of refactors and changes.
Is someone do this before ?
We are living in 2019, and in most cases, if you search something on the internet, you will find that already somebody does this before you and this one is
And of course, there is a lot of databases already on the market. Few of them are open source, and their code is available for reverse engineering on GitHub. I would use SQL Lite, which (as my database in future) will keep all data in the file.
Go ahead
Let’s start some coding, from articles how basic interface from databases should look different. When you
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import Foundation func readExecuteLoop(){ while(true){ print("sdb>", terminator:"") let input:String = (readLine())! if input.contains("quit"){ break } else if input.contains("insert"){ insert(statement: input) } else if input.contains("select"){ } } } |
I don’t like really this if-else part, this will be probably changed in the future. My whole project basically contains 3 files:

Crud file is not much filled now, and contains only empty methods:
1 2 3 4 5 6 7 |
func insert(statement:String ){ print("Here we will execute insert statement") } func select(statement:String){ print("Here we will execute select statement") } |
And if I good understand Swift, in main there is only execution of one method:
1 |
read_execute_loop() |
After execution, code should looks like below:

This is all in this part, next we try to improve some code and maybe insert some data! See you