Hello everyone, I was wondering if there is a way to dynamically add a table to a SQL database off of a button click coded in C#. I'm not asking for all of the code, I just need a small push in the right direction.
Thank you,
Ryan
You can write up some dynamic SQL in a proc passing the table name as parameter and create the table. But I would be concerned about letting users create objects on the fly. Can you explain more about the business logic? Do you have any process in place to clean up such tables on a periodic basis?
|||Ok, well I am making a quiz engine and with this I want each client that makes an account on the website to be able to create, edit, and deploy their own quiz on my site. By allowing users to create their quiz in separate tables they will be able to easily edit their quiz because of the separate tables. If I mashed many quizzes into one table I feel it would get too unorganized. The number of quizzes/tables each user can make will be limited so a client cannot easily flood the database. An admin account will be able to edit and or delete every quiz made by any user as well.
Would you mind elaborating more on writing dynamic SQL like you said above. Maybe some code is required here because I'm not very experienced in anything SQL. I understand what you said, but I have no idea where to start.
|||That doesnt sound like a very good design. You can create the records in one table and identify them by userId or username so when you have to pull out the records you can do so by username. Otherwise there will be LOT of dynamic SQL and it will make the server crawl.. because you dont know what table to select from.
This is an important read before you think of dynamic SQL:The Curse and Blessings of Dynamic SQL
|||Thank you for pointing out the flaws in my design, I have taken your advice and will be calling rows based on each username. I've already had issues with my new way but I'll make a new post in the correct section. Thank you for the read as well.
No comments:
Post a Comment