Skip navigation links

MySQL Forums :: Database Design and Data Modelling :: Combining multiple tables by date/time


Advanced Search

Combining multiple tables by date/time
Posted by: Dion Houston Sr ()
Date: November 06, 2009 07:57PM

Hi all,

Full disclosure, I'm not actually doing this in MySQL, but I couldn't find any general database modeling forums and I need help. :)

I am trying to model a database containing information about events from different sources. All of these tables have date and time (DATETIME and INT respectively), and I've added an integer primary key to each table.

To make it a bit more concrete, say for example table1 and table2 look like

PKEY, DATE, TIME, DESCRIPTION
PKEY, DATE, TIME, CATEGORY, LOCATION, etc.

The desired end state is a query which produces

DATE, TIME, DESCRIPTION, CATEGORY, LOCATION, etc.

Which contains all records in both tables (my real model currently has 4 tables). Currently the way that I'm doing it is by having an additional table in the form

PKEY, DATE, TIME, table1ID, table2ID

Which I populate with the key of the appropriate table in the appropriate field and then join.

The biggest issue I have with this approach is that each change I make to table1 or table2 requires me to make an appropriate change in the additional table. If possible I'd like to do this through modeling instead. Secondarily, I imagine that as I add sources that the performance of this will be close to O(N^2).

Does anyone have any suggestions on how to improve this scenario? I'm quite a bit rusty on SQL, but I don't recall an easy way to do this. Theory rather than actual code is most appreciated, but any suggestions I'll make work.

Thanks in advance,

Dion

Options: ReplyQuote


Subject Written By Posted
Combining multiple tables by date/time Dion Houston Sr 11/06/2009 07:57PM
Re: Combining multiple tables by date/time Rick James 11/07/2009 10:06PM


Sorry, only registered users may post in this forum.