Who breaks up the stories into tasks? By scrum master? or by team members?
The Project team breaks up stories into tasks. Since they are the ones doing the actual work, they are best equipped to determine what smaller steps are needed in order to complete the story. The scrum masters sole purpose is to serve the team and ensure the process is moving along smoothly. This means calling (not leading) the meetings, removing any impediments, clearing blockages, and anything else that may disrupt the success of the project.
When to break up the stories? before/during/after the sprint planning?
Tasks are broken up in the Sprint Planning meeting before the entire team. The scrum master and Product owner is highly recommended to be present at this meeting to help the team set priorities for the work accomplished. The scrum master isn't required but attending may very well, in my opinion, help him/her do their job better.
How to break up the stories? By technologies, e.g. data-modeling, sql, or by use cases (each story may have several use cases, and error handling).
Tasks should be broken up into completable tasks, that operate in one of two states. Done and Not Done. If a task can easily be caught in some sort of stasis, in limbo of "kinda done but not", and not easily (and very black and white) DONE or NOT DONE, then you need to break it down more. For instance, Complete payment gateway for ecommerce site would be a task because although several things need to take place in order for this to be done (set up secure transaction, integrate payment API into code, create web form, etc.), these all collectively sum up something that can be completed in about 1 or two days. If the payment gateway works fine but is not secure, then the answer to "Is it done?" isn't "well...it's a simple no." At my old job, we tried to make sure that tasks could be completed within 1-2 days, and stories should be completed within the sprint. (if the sprint was 10 days, we tried to have about 5x2-day tasks assocaited with it). i hope that answers ur question.