My company is storing its data in an Oracle database.
It offers services to several other companies, each of them having thousands of customers placing orders.
For historical reasons, all of the data are in the same schema and, for example, all orders are in the same table, say ORDERS
.
It now has performance problems and I'd like to take this opportunity to manage two goals :
- eradicate performance problems
- separate companies data for security concerns.
My initial thought was to use one schema for each company we serve :
- schema
A
with a table namedORDERS
containing all of the orders of company A customers - schema
B
with a table namedORDERS
containing all of the orders of company B customers - etc. ...
but we have another concern : we also have some "super-companies" which also can manage data for many companies. For exemple : "supercompany" managing orders for both companies A and B.
With this approach, is there any mean to manage these "supercompany" ? I thought declaring another schema (let's say SUPERCOMPANY
) having a synonym which refer to the union of ORDERS
tables from A
and B
but :
- Is there any performance problem having a synonym referencing a union ? Are tables' indexes used ?
- How about INSERT ? How to target the appropriate table if "supercompany" wants to add an order for a customer which belong to company A ?
Should we better use another solution, like still having one big database and having schemas referecing appropriate partition of the big table ORDERS
? (I don't even know if this is possible)
- schema
DB
containing data with hugeORDERS
table, partitionned by company. - schema
A
having a synonym referencingDB.ORDERS#partitionA
- schema
B
having a synonym referencingDB.ORDERS#partitionB
- schema
SUPERCOMPANY
having a synonym referencingDB.ORDERS
orDB.ORDERS#partitionA and ORDERS#partitionB
It doesn't sound good to me because we shouldn't directly target partitions, are we ?
I still have hope and I'm sure Oracle has solutions for such problems since it is a major player for relational databases.
What would be your approach ?
Thanks for your reading.