Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Table alias, Should I use a view?

Author  Topic 

sql777
Constraint Violating Yak Guru

314 Posts

Posted - 2007-11-13 : 11:34:25
Hi,

I am designing my database so that other web applications can easily "integrate" into mine.

So I want to use an 'alias' for my users table, meaning whenever I reference my tblUsers I will use xUsers. So if someone wants to integrate another application they can simply modify the xUsers 'view' and reference another users table and still have the application work as normal.

Hope I am clear.

Anyhow, a view is what I should create right?

So people can then do:

UPDATE xUsers

Delete xUsers

Select ... from xUsers

correct?

Hommer
Aged Yak Warrior

808 Posts

Posted - 2007-11-13 : 12:09:40
Generally speaking, view is the right answer. If you build package software for others to use, you could use views to hide your underlying tables.

I am not quite sure that is the benifit you are after here. Who are "they" in your case, other developers, power users? If you let them modify your view, then there is no different just to let them modify the table itself.

Adding a view is still a performance hit.
Go to Top of Page

sql777
Constraint Violating Yak Guru

314 Posts

Posted - 2007-11-13 : 12:50:24
Say I'm making a blog software, and it has a users table.

Now say someone wants to integrate a forums application, the users table has to be synched up somehow.
If I use a view, then one could easily modify the view to SELECT from the forums users table.

example:

say my view looks like:

MyView

Select *
from tblUsers (<---- REAL TABLE)


Now if someone wants to integrate a forums software, they have to change my view so that it pulls data from the other applications users table

Select *
from snitz_Users

Makes sense? (all the while my other stored procedures will continue to work just fine, you might have to add some columns to the other user table but it isn't THAT much work really to do that).

Go to Top of Page

evilDBA
Posting Yak Master

155 Posts

Posted - 2007-11-13 : 12:59:39
I dont think that it is realistic

Lets say your user has an Address, FirstName and LastName (First='John', Last='Smith')
You integrate a forum where users have Address, and Name ('John Smith'), and Address is in a different format (with/without zip codes etc)
What are you going to do?

I cant imagine that you can 'merge' different applications to use the same table except some trivial cases.
Go to Top of Page
   

- Advertisement -