I'm not an expert on DataBase programming/design/engineering/etc, so I've got a simple question regarding the correct way one should connect to a DataBase.
I'm working on a Client UI on Java that must check every two seconds for updates on a DB. The Client and the DB are located in different places and connected through a VPN (server hosting place - home).
There are two methods that I've considered for connecting to the Server:
(1) By executing queries directly from [client] -> [database]
(2) By hosting a simple PHP service that executes queries locally: [client] -> [php -> database]. (the client consumes the PHP service, the PHP service executes a query)
Now, if the two PCs (client and DB) are connected within the same LAN, the updating delay for each solution is basically the same. BUT If I ran the same two solutions from home (via the VPN) I noticed that (1) takes about 14 seconds to complete, whereas (2) is very fast.
So, a question to the people that know about DB programming/managing: In terms of design, which of (1) and (2) should be implemented and is correct?