Re:SQLite Is Serverless
by dragontamer on Monday January 27, 2020 @05:54PM
(#22164722)
>> "A proper database would have a 'billing address is same as delivery address logic"
> The database does not have logic like this.
Of course it wouldn't have 'logic', databases are just stores of data.
You'd have one 'address' table, with probably a int-primary/surrogate key. Then the 'delivery' and 'billing' address would be an int, pointing to the address table.
Furthermore, the billing and delivery address would be foreign keys, so the internal database logic would keep the tables in sync with no application code required.
With the data organized in this manner, the application code becomes logic free and braindead easy to write. Or at least, corner cases become easier to handle and more explicit. (Say two customers share the same address, do you allow repeats in the address table? Or do you allow customers to tie address information together? Either way, your decision rests on how you define the primary key)
> When I have application server all such logic (if applicable) is handled by code in much more performant way.
The most performant way is no logic at all. A proper database removes a lot of checks, the storage format itself naturally creates logic free code.
Some application logic is necessary of course. But you can minimize the logic needed by thinking about data layout.
> The database does not have logic like this.
Of course it wouldn't have 'logic', databases are just stores of data.
You'd have one 'address' table, with probably a int-primary/surrogate key. Then the 'delivery' and 'billing' address would be an int, pointing to the address table.
Furthermore, the billing and delivery address would be foreign keys, so the internal database logic would keep the tables in sync with no application code required.
With the data organized in this manner, the application code becomes logic free and braindead easy to write. Or at least, corner cases become easier to handle and more explicit. (Say two customers share the same address, do you allow repeats in the address table? Or do you allow customers to tie address information together? Either way, your decision rests on how you define the primary key)
> When I have application server all such logic (if applicable) is handled by code in much more performant way.
The most performant way is no logic at all. A proper database removes a lot of checks, the storage format itself naturally creates logic free code.
Some application logic is necessary of course. But you can minimize the logic needed by thinking about data layout.