January 28, 2009 at 6:17 am
hi,
i work with sql server 2005 and i'm a real beginner in t sql.
I have two table denomination1, denomination2
each table have the same definition:
denominationId pk,
description varchar(500)
...
now i must to create a join table as deno1_deno_2
In this table i must to have the id of deno1 and the id of deno2
i must to create link between this new table and the two others;
deno1 => relation 1 at n (one to several)
deno2 => relation 1 at 1
how i can do for create this ?
January 28, 2009 at 6:58 am
Couple of things...
This looks like a homework problem. Most people here, including me, won't actually give you code to help because of this...
I can however point you in the right direction. Check out books online, you want to read about Constraints, Creating them etc and in particular foreign key constraints that should at least get you started.
Also have a look at the following article on how to get better answers to your questions here... http://www.sqlservercentral.com/articles/Best+Practices/61537/
January 28, 2009 at 7:01 am
And you might want to talk to your instructor. That's a really poor example to show proper database use. Two tables with the same names, columns and data types? Serious violation of data normalization.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 30, 2009 at 2:52 am
hi,
thanks for your comment but it's not a course it's on a society !
it's not me the database administrator but i have a littile developement that i must to realize !!!!
we have a db A who contains a table deno1
and a db B who contains a deno2
with the same ident (primary key and so on )
there is a view with data from db B place db A for to acces
Now how i can create a table who joins my firts table deno1 as foreign key and the view as a foreign key too !
is it possible ?
Thanks for your time
christophe
January 30, 2009 at 3:55 am
So it's two different databases? You can join the tables together in a query by referrencing the database name, but you can't create a foreign key across databases.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
February 2, 2009 at 7:37 am
your question, is, however, in the wrong category
you should post questions like this in the 2005 Newbies thread
that thread seems to be filled with advanced qustions about best practices for intermediate DBA's
February 2, 2009 at 8:14 am
Hi everybody,
thanks for your time
yes i can use for to have information from other database i can use the database name
select * from databaseOther.dbo.deno1
Have a nice day
Christophe
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply