The information model I am modelling from includes an "any type". For example a customer can have zero or more 'entries' each of which can have a number of values. Each value could be a either date, numeric, string or spatial. Note query performance is more important than insert performance.
I wondering if you have any ideas for table design.
My ideas are: (a) a single table encompassing all the types. Each record in entry_data would only use one column for the value. Also each valuetype column needs to be indexed. This seems a little wasteful (although I'm aware oracle won't index the null values )
create table entry (
id number(12) primary key,
name varchar2(256) not null unique,
datatype varchar2(256) not null,
customer_id not null references customer(id)
);
create table entry_data (
id number(12) primary key,
entryid number(12) not null references entry(id),
strvalue varchar2(256), -- index
datevalue date, -- index
numvalue number, -- index
sdo_geometry geom -- index
);
OR (b) create a separate entry_data table for each type
create table entry (
id number(12) primary key,
name varchar2(256) not null unique,
datatype varchar2(256) not null,
customer_id not null references customer(id)
);
create table entry_data_str (
id number(12) primary key,
entryid number(12) not null references entry(id),
strvalue varchar2(256), -- index
);
-- etc
but I'm not sure if introducing more joins will impact the performance.
Any suggestions welcome. Thanks.
entry_data_*
, I think you'd have a problem where you first must query to find out whichentry_data_*
table to query and then actually queryentry_data_*
.