Solved

Oracle reference many tables with one table

Posted on 2014-11-08
2
269 Views
Last Modified: 2014-11-09
I have a number of solutions for this problem but want to choose the correct one and hope to hear a consensus of what experts think one having one table (Notes) which can have references to many tables.

So imagine you have a Company, User and Trade table.  Users belong to companies and trades belong to users which is all well laid out.  Now, I have to resolve the issue of how to resolve Notes because each of those tables can have notes.  So you can have notes for a person and/or company and/or trades.

What is the best way to implement this?

Oracle 12c with millions of rows per year with a minimum of 7 years activity.

Any help is GREATLY appreciated.

Thanks in advance,

B
0
Comment
Question by:cyimxtck
2 Comments
 
LVL 34

Accepted Solution

by:
johnsone earned 500 total points
ID: 40431146
Single table:

NOTES
NOTE_ID       NUMBER
NOTE_TXT      VARCHAR2(4000)
CREATE_DATE   DATE

Primary key NOTE_ID.  Partition by CREATE_DATE to make truncating out notes easier.  I don't see a performance gain there because the date won't be part of any query.

If you need multiple fields, add a NOTE_SEQ field to sequence the records associated with the NOTE_ID.

All tables that have a note would have a foreign key to this table.

To drop out old notes,  you would have to update the NOTE_ID of the referencing tables to NULL and then drop the partition.
0
 

Author Closing Comment

by:cyimxtck
ID: 40431246
What I needed for sanity!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  â€¦
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to recover a database from a user managed backup

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question