Strange Use of Database Schema (Namespace)

schema

Database schema helps grouping tables, or help identify multiple tables that have the same table name. Most of the schema usage that I have found so far are for grouping tables, isolating tables among the users (or talents), allow different permission based on the schema.

In my case, I have a predefined table definition, and I like my user to be able to duplicate this table multiple times in my application. Obviously, I can't have the user create the new tables with the same name. My original idea is to allow the user specify a table name suffix:

e.g.
[TableA]
[CustomName_TableA]
[OtherName_TableA]

However, this requires a bit of code change since the table name is hardcoded in the data access layer of the application.

What are the drawbacks, or potential issues if I create a new schema when a user duplicate the table, instead of dynamically generate a new table name?

e.g.
[dbo].[TableA]
[CustomName].[TableA]
[OtherName].[TableA]

Best Answer

Please elaborate more on your use case. The solutions I can think of are: 1- Using a prefix for the table to be used by the table name (username_TABLE)

2- using Temporary tables then exporting the review into a new table (then you would add a new column to the table and the content of that column will be the username): Example fields: USERID, COLUMN1, COLUMN2, etc.

3- Using a view. Using a view, you could actually use the same "table" name (applications don't know the difference between a view/table), then again you could use an extra column in your underlying table.