Click here to Skip to main content
14,691,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dears,

I need to log transaction requests and responses to database
But shall I log them in a single table with a relationship within the same table
or it's better to have 2 tables (one for request and one for response) ?

Regards,
Posted

Database design has no exact answer. It always depends on what you want to do. How will you use the data? How much data do you anticipate of each kind? On the one hand if they are in the same table to get a report you don't have to union but if you won't need to union often then keep them separate. If they will share all the same fields then keep them in the same table.

Essentially, the answer is it depends. You'll have to decide.
   
Comments
Sandra Ha 19-Sep-13 8:02am
   
yes they have the same structure (same fields) and the data will be used for reporting. Some data will be taken from request records and some from responses.
ZurdoDev 19-Sep-13 8:04am
   
Probably put them in the same table then with a field to indicate if it is a request or response.
gvprabu 19-Sep-13 8:49am
   
nice explanation.... my 5+ :-)
It depends on how response are related with single request.
1) Relationship: 1 request to 1 response
One table

2) Relationship: 1 request to many responses
Two tables

Please, read these:
Relational database[^]
Relational model of database[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900