At the moment I have a table setup that looks somewhat like this:
create table tbl_locationcollections
(
id int(11) PRIMARY KEY IDENTITY, --(Primary Key),
name varchar(100) not null,
cleanname varchar(100) not null,
typeid int(11) not null (foreign key)
)
create tbl_locationcollectiontypes
(
id int(11) PRIMARY KEY IDENTITY, --(Primary Key)
type varchar(100)
)
a type would be something like: country, state, city etc etc.
I would then join to the various type tables like this:
create tbl_states2locationcollection
(
id int(11) PRIMARY KEY IDENTITY, --(Primary Key)
stateid int(11) not null, --(foreing key)
locationcollectionid int(11) not null --(foreign key)
)
with other tables like tbl_cities2locationcollection etc etc.
Is this style of seperation better for speed and readability than having a table such as:
create tbl_locations2collection
(
id int(11) PRIMARY KEY IDENTITY, --(Primary key)
locationid int(11) not null, --(foreign key to the type of: state, country, city)
typeid int(11) not null --(foreign key)
)
where all the different types are mixed in together.
the only downside i can see for not having a mixed table, is having to create a specific table for each type that is created in the future.