Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 367265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:42:41+00:00 2026-05-12T13:42:41+00:00

I have 3 different transaction tables, which look very similar, but have slight differences.

  • 0

I have 3 different transaction tables, which look very similar, but have slight differences. This comes from the fact that there are 3 different transaction types; depending on the transaction types the columns change, so to get them in 3NF I need to have them in separate tables (right?).

As an example:
t1:
date,user,amount

t2:
date,user,who,amount

t3:
date,user,what,amount

Now I need a query who is going to get me all transactions in each table for the same user, something like

select * from t1,t2,t3 where user=’me’;
(which of course doesn’t work).

I am studying JOIN statements but haven’t got around the right way to do this. Thanks.

EDIT: Actually I need then all of the columns from every table, not just the ones who are the same.


EDIT #2: Yeah,having transaction_type doesn’t break 3NF, of course – so maybe my design is utterly wrong. Here is what really happens (it’s an alternative currency system):
– Transactions are between users, like mutual credit. So units get swapped between users.

– Inventarizations are physical stuff brought into the system; a user gets units for this.
– Consumations are physical stuff consumed; a user has to pay units for this.

|--------------------------------------------------------------------------|
|  type     |  transactions       |  inventarizations  |  consumations     |
|--------------------------------------------------------------------------|
|  columns  |  date               |  date              |  date             |
|           |  creditor(FK user)  |  creditor(FK user) |                   |
|           |  debitor(FK user)   |                    |  debitor(FK user) |
|           |  service(FK service)|                    |                   |
|           |                     |  asset(FK asset)   |  asset(FK asset)  |
|           |  amount             |  amount            |  amount           |
|           |                     |                    |  price            |
|--------------------------------------------------------------------------|

(Note that ‘amount’ is in different units;these are the entries and calculations are made on those amounts. Outside the scope to explain why, but these are the fields).
So the question changes to “Can/should this be in one table or be multiple tables (as I have it for now)?”
I need the previously described SQL statement to display running balances.

(Should this now become a new question altogether or is that OK to EDIT?).

EDIT #3: As EDIT #2 actually transforms this to a new question, I also decided to post a new question. (I hope this is ok?).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:42:42+00:00Added an answer on May 12, 2026 at 1:42 pm

    You can supply defaults as constants in the select statements for columns where you have no data;

    so

    SELECT Date, User, Amount, 'NotApplicable' as Who, 'NotApplicable' as What from t1 where user = 'me'
    UNION
    SELECT Date, User, Amount, Who, 'NotApplicable' from t2 where user = 'me'
    UNION
    SELECT Date, User, Amount, 'NotApplicable', What from t3 where user = 'me'
    

    which assumes that Who And What are string type columns. You could use Null as well, but some kind of placeholder is needed.

    I think that placing your additional information in a separate table and keeping all transactions in a single table will work better for you though, unless there is some other detail I’ve missed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 queries which display 2 different values but the results from one
I have different php output in jQuery-based tabs. This output is formed from database
I am currently writing an application which will have a lot of transaction. Each
I have needs to keep some of log data in different tables even my
I have 5 databases which represent different regions of the country. In each database,
I have a class which does operations on the database, but I want to
I have a mySQl innodb database which has a couple of tables which store
I have set up transactional replication between two SQL Servers on different ends of
I have different urls that points to the same code www.url1.com www.url2.com I need
I have different projects written in .NET 3.5 and some unit test projects to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.