Hi
I'm setting up an SQLIte database within my C application that will be used as an intermediate stage in converting filetypes. My design tries to keep data normalized - for example, i have an Entity table, and in that table each entity has an integer type.
There is another EntityTypes table with a string value for the type, and an integer primary key ID. The two are linked using a foreign key constraint.
i.e:
"create table Entities(
ID integer primary key not null unique,
Name varchar(512),
Type integer,
File integer,
Filepos integer,
foreign key (File) references Files(ID),
foreign key (Type) references EntityTypes(ID));"
"create table EntityTypes(
ID integer primary key not null unique,
Name varchar(512));"
When I want to insert an entity (foo) into the Entity table, I could do so armed with only the entity type name (bar) by using a subquery (ignoring the file stuff in the table):
insert into Entities(Name, Type) values ('foo', (select ID from EntityTypes where Name='bar'));
But since I'm diong this all from inside my own app, I can also just make sure that I populate EntityTypes with ID, Name pairs that I know about (enum'd values and string->enum routines for example).
My question is: am I defeating the purpose of having a normalized design by keeping these enum values/routines? I presume I am going to see a gain in performance by not having to keep looking up the values in the EntityTypes table with every insert , or am I ignoring a likely caching/other efiiciency?
Essentially it feels like I'm adding code that I might not actually need.
Your thoughts most appreciated!
Software/Hardware used:
C SQLite
ASKED:
Mar 16, 2010 5:29 PM GMT
UPDATED:
March 17, 2010 9:30:14 AM GMT