I'm writing a database management software. It has a client-server architecture where the server has the piece of code to store and retrieve. The client has to get the input from the user, connects to the server and queries it. Now I have a parser that can parse SQL like queries. My question is which is the best place to embed this parser? Option 1-Embedding it in the Server:Get the queries from the client, pass it untouched to the Server and then parse it and do the needful. (OR)Option 2-Embedding it in the Client:Get the queries from the Client, parse it then and there and then pass a command object that has specific fields set reflecting the queries to the server and the server acts upon the data in the command object. Which is the right way to do?
The right place to embed a parser : Server or the Client?
c;server;parsing;client
It depends. If you need to query the server for getting a lot of metadata to do the parsing, then parsing on the client can cause a lot of additional roundtrips (additional to the ones for executing the query itself). On the other hand, if the client can parse the query and make a syntax check beforehand, without talking to the server, you may need less roundtrips than if you need to ask the server first to see if the query was syntactically correct.Another question is if the parser needs a lot of CPU time; this would be a reason to place it on the client, to avoid getting your server a bottleneck.And a third thing to consider is how easy it is to use the parser on the client or the server, which may depends to some degree on the programming languages you are using and how you actually do the embedding. I guess this is not a problem in your case (since it is so obvious you would otherwise would have mentioned it).