hi there,
i have the following joining table (many-to-many relationship)...
CREATE TABLE [dbo].[products_to_products_swatch] (
[products_to_products_swatch_id] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
[product_id] [int] NOT NULL ,
[products_swatch_id] [int] NOT NULL
) ON [PRIMARY]
GO
question: do i need to include a primary key in this table - being that it is a joing table?
thanks
mikejoing table ? i mean joining table :o)|||If this is simply implementing a many-to-many join, then there is no need for a surrogate key. Just declare a composite primary key consisting of the foreign keys to both tables.
If you are storing additional information regarding the relationship (timestamp, notes, modifier, whatever) you may want to include a surrogate key for developmental consistency with your other tables, but it is not required.
Showing posts with label dbo. Show all posts
Showing posts with label dbo. Show all posts
Tuesday, March 20, 2012
Sunday, March 11, 2012
Best practice for dbo
When setting up databases for end users, what's the best practice regarding who's the dbo for each individual database - the user itself or a sysadmin?
Does it really have any importance at all who the owner (as defined by 'dbo') is ?I'd strongly recommend leaving sa as dbo, and if need be then making the user a member of the db_owner role if you need that.
-PatP|||Thanks.
The issue was raised when I noticed that for older user databases, someone had assigned a system admin as the dbo by his own, personal user name. When than person then left, and his user was removed, those user databases became orphans.|||You can assign db_ddladmin.
db_ddladmin act same as dbo but it has limited rights comparing db_owner.|||I suspect that Coolberg's problem wasn't one of permission level (they want the user to be equivalent to dbo), but one of ownership (they don't want the login to "own" the database).
There are two issues here that are tightly intertwined, and often confused.
A login is what gives a person access to SQL Server. Logins exist at the server level, and can be either SQL Authenticated or Windows Authenticated. Logins are what "own" a database.
A User is what gives a person permissions inside a SQL Server database. Users exist only inside a database, and are logically tied to exactly one login on the server.
I think that Coolberg wants to keep the ownership of the database limited to an administrative login. I strongly recommend using sa (because you just about can't delete that login), but I agree with the general idea regardless of what login you use.
By using this strategy, you can keep the database ownership limited to an administrative login, but still make any database users memebers of the db_owner role (giving them exactly the same permissions as dbo).
-PatP|||Thanks.
Yes, I'll go for the sa user.
My main goal is to avoid getting orphanized databases when users are leaving in the future.
Does it really have any importance at all who the owner (as defined by 'dbo') is ?I'd strongly recommend leaving sa as dbo, and if need be then making the user a member of the db_owner role if you need that.
-PatP|||Thanks.
The issue was raised when I noticed that for older user databases, someone had assigned a system admin as the dbo by his own, personal user name. When than person then left, and his user was removed, those user databases became orphans.|||You can assign db_ddladmin.
db_ddladmin act same as dbo but it has limited rights comparing db_owner.|||I suspect that Coolberg's problem wasn't one of permission level (they want the user to be equivalent to dbo), but one of ownership (they don't want the login to "own" the database).
There are two issues here that are tightly intertwined, and often confused.
A login is what gives a person access to SQL Server. Logins exist at the server level, and can be either SQL Authenticated or Windows Authenticated. Logins are what "own" a database.
A User is what gives a person permissions inside a SQL Server database. Users exist only inside a database, and are logically tied to exactly one login on the server.
I think that Coolberg wants to keep the ownership of the database limited to an administrative login. I strongly recommend using sa (because you just about can't delete that login), but I agree with the general idea regardless of what login you use.
By using this strategy, you can keep the database ownership limited to an administrative login, but still make any database users memebers of the db_owner role (giving them exactly the same permissions as dbo).
-PatP|||Thanks.
Yes, I'll go for the sa user.
My main goal is to avoid getting orphanized databases when users are leaving in the future.
Monday, February 13, 2012
Beginner Stored Procedure Help
If create a stored procedure like this:
create procedure dbo.usp_trxn_enum
(
@.a_trxn_type_cd char(2) = null
, @.a_allowed_mainframe_file_cd char(7) = null
)
<snip other code>
Is it executed like this:
exec dbo.usp_trxn_enum 'XX', 'XXXXXXX'
Thanks,
--
JerryYes.
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
"Jerry" <jerryalan@.gmail.com> wrote in message
news:1156878844.414057.127090@.74g2000cwt.googlegroups.com...
If create a stored procedure like this:
create procedure dbo.usp_trxn_enum
(
@.a_trxn_type_cd char(2) = null
, @.a_allowed_mainframe_file_cd char(7) = null
)
<snip other code>
Is it executed like this:
exec dbo.usp_trxn_enum 'XX', 'XXXXXXX'
Thanks,
--
Jerry|||Jerry wrote:
> If create a stored procedure like this:
> create procedure dbo.usp_trxn_enum
> (
> @.a_trxn_type_cd char(2) = null
> , @.a_allowed_mainframe_file_cd char(7) = null
> )
> <snip other code>
> Is it executed like this:
> exec dbo.usp_trxn_enum 'XX', 'XXXXXXX'
> Thanks,
>
Yes, or
EXEC dbo.usp_trxn_enum
@.a_trxn_type_cd = 'XX',
@.a_allowed_mainframe_file_cd = 'XXXXXXX'
Tracy McKibben
MCDBA
http://www.realsqlguy.com
create procedure dbo.usp_trxn_enum
(
@.a_trxn_type_cd char(2) = null
, @.a_allowed_mainframe_file_cd char(7) = null
)
<snip other code>
Is it executed like this:
exec dbo.usp_trxn_enum 'XX', 'XXXXXXX'
Thanks,
--
JerryYes.
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
"Jerry" <jerryalan@.gmail.com> wrote in message
news:1156878844.414057.127090@.74g2000cwt.googlegroups.com...
If create a stored procedure like this:
create procedure dbo.usp_trxn_enum
(
@.a_trxn_type_cd char(2) = null
, @.a_allowed_mainframe_file_cd char(7) = null
)
<snip other code>
Is it executed like this:
exec dbo.usp_trxn_enum 'XX', 'XXXXXXX'
Thanks,
--
Jerry|||Jerry wrote:
> If create a stored procedure like this:
> create procedure dbo.usp_trxn_enum
> (
> @.a_trxn_type_cd char(2) = null
> , @.a_allowed_mainframe_file_cd char(7) = null
> )
> <snip other code>
> Is it executed like this:
> exec dbo.usp_trxn_enum 'XX', 'XXXXXXX'
> Thanks,
>
Yes, or
EXEC dbo.usp_trxn_enum
@.a_trxn_type_cd = 'XX',
@.a_allowed_mainframe_file_cd = 'XXXXXXX'
Tracy McKibben
MCDBA
http://www.realsqlguy.com
Beginner Stored Procedure Help
If create a stored procedure like this:
create procedure dbo.usp_trxn_enum
(
@.a_trxn_type_cd char(2) = null
, @.a_allowed_mainframe_file_cd char(7) = null
)
<snip other code>
Is it executed like this:
exec dbo.usp_trxn_enum 'XX', 'XXXXXXX'
Thanks,
JerryYes.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
"Jerry" <jerryalan@.gmail.com> wrote in message
news:1156878844.414057.127090@.74g2000cwt.googlegroups.com...
If create a stored procedure like this:
create procedure dbo.usp_trxn_enum
(
@.a_trxn_type_cd char(2) = null
, @.a_allowed_mainframe_file_cd char(7) = null
)
<snip other code>
Is it executed like this:
exec dbo.usp_trxn_enum 'XX', 'XXXXXXX'
Thanks,
Jerry|||Jerry wrote:
> If create a stored procedure like this:
> create procedure dbo.usp_trxn_enum
> (
> @.a_trxn_type_cd char(2) = null
> , @.a_allowed_mainframe_file_cd char(7) = null
> )
> <snip other code>
> Is it executed like this:
> exec dbo.usp_trxn_enum 'XX', 'XXXXXXX'
> Thanks,
>
Yes, or
EXEC dbo.usp_trxn_enum
@.a_trxn_type_cd = 'XX',
@.a_allowed_mainframe_file_cd = 'XXXXXXX'
Tracy McKibben
MCDBA
http://www.realsqlguy.com
create procedure dbo.usp_trxn_enum
(
@.a_trxn_type_cd char(2) = null
, @.a_allowed_mainframe_file_cd char(7) = null
)
<snip other code>
Is it executed like this:
exec dbo.usp_trxn_enum 'XX', 'XXXXXXX'
Thanks,
JerryYes.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
"Jerry" <jerryalan@.gmail.com> wrote in message
news:1156878844.414057.127090@.74g2000cwt.googlegroups.com...
If create a stored procedure like this:
create procedure dbo.usp_trxn_enum
(
@.a_trxn_type_cd char(2) = null
, @.a_allowed_mainframe_file_cd char(7) = null
)
<snip other code>
Is it executed like this:
exec dbo.usp_trxn_enum 'XX', 'XXXXXXX'
Thanks,
Jerry|||Jerry wrote:
> If create a stored procedure like this:
> create procedure dbo.usp_trxn_enum
> (
> @.a_trxn_type_cd char(2) = null
> , @.a_allowed_mainframe_file_cd char(7) = null
> )
> <snip other code>
> Is it executed like this:
> exec dbo.usp_trxn_enum 'XX', 'XXXXXXX'
> Thanks,
>
Yes, or
EXEC dbo.usp_trxn_enum
@.a_trxn_type_cd = 'XX',
@.a_allowed_mainframe_file_cd = 'XXXXXXX'
Tracy McKibben
MCDBA
http://www.realsqlguy.com
Labels:
a_allowed_mainframe_file_cd,
a_trxn_type_cd,
beginner,
char,
create,
database,
dbo,
microsoft,
mysql,
null,
oracle,
procedure,
server,
sql,
stored,
thiscreate,
usp_trxn_enum
Subscribe to:
Posts (Atom)