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
 General SQL Server Forums
 Database Design and Application Architecture
 TransactionType

Author  Topic 

programer
Posting Yak Master

221 Posts

Posted - 2011-08-29 : 15:15:04
Hi,

I have table tbl_transaction in which is column TransactionType int


I have a problem, because I wanted to add different information, such as:
- Withdrawal
- deposit
- Friendship Bonus / user1
- Friendship Bonus / user2
- Friendship Bonus / user3

So how do I create a table according to my needs?

Please help!

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-08-29 : 16:53:10
You can create a reference table that lists all the transaction types - for example like this:

create table dbo.TransactionTypes
(
transaction_type_id int not null primary key clustered,
transaction_type_description varchar(256) not null
)
Then insert all the possible transaction types with an integer id and a description into that table.

You may also want to add a foreign key constraint on the tbl_transaction to refer to this newly created table, like this:
alter table tbl_tranasaction
with check add constrain FK_Transaction_TransactionType foreign key(TransactionType)
references TransactionTypes(transaction_type_id)
Go to Top of Page

programer
Posting Yak Master

221 Posts

Posted - 2011-08-30 : 17:11:13
quote:
Originally posted by sunitabeck

You can create a reference table that lists all the transaction types - for example like this:

create table dbo.TransactionTypes
(
transaction_type_id int not null primary key clustered,
transaction_type_description varchar(256) not null
)
Then insert all the possible transaction types with an integer id and a description into that table.

You may also want to add a foreign key constraint on the tbl_transaction to refer to this newly created table, like this:
alter table tbl_tranasaction
with check add constrain FK_Transaction_TransactionType foreign key(TransactionType)
references TransactionTypes(transaction_type_id)




If I want to save different description in the table, is the best solution If I use in one table TransactionType and TransactionDesc.

Column TransactionType is for orderby, and column TransactionDesc for description.

Is this ok solution?

Regards
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-31 : 00:14:27
what would be relation b/w transaction type and description? if its 1 to 1 you can have description in same table itself. if not better to go for a separate description table

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -