You need to better understand the properties that you are working with. In your code f is a folderitem and db is a RealSqlDatabase class.
returns a folderitem so long as the user did not click the cancel button in the dialog window. If you look up the REALSQLDatabase class in the LR you will see that the dabaseFile property is a folderitem and so
is assigning that folderitem to the databasefile property of db. db now has the name, the path, and all of the other properties of a folderitem, not just the name. You are in essence assigning the location of the database file, not just the name.