Solved

Oracle reference many tables with one table

Posted on 2014-11-08
2
265 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.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
apply oracle patches on windows error 2 42
null value 15 70
Oracle Subquery bad Join 11 46
Fastest way to replace data in Oracle 5 28
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to take different types of Oracle backups using RMAN.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now