Hi
you check if the app has already run via a number of ways..
- set a variable in the registry
- set a variable in a config file
- etc
however, creating tables in sql and so on is probably something you would better do via custom actions while installing your application:
http://blogs.msdn.com/astebner/archive/2005/10/30/487015.aspx
Hope this helps you out