Hi Guys,
I'm working on a simple aircraft classified ad application. I'm designing the main tables for the classified ads. The initial app was written with everything in one big table, but I'm trying to simplify it down into several smaller tables. (normalization)
-Core (main data)
-categories
-details
-features
Core is the main table. This includes the essential information (title, id of member who listed ad) and is going to be the core table to be included in search results. Basically, when someone is browsing listings, the core table includes the data that is included for the ad in each listing.
Categories is self explanatory. This table includes the categories that are bound to the ad.
The difference between details and features is that the details table will include data that requires custom entry about specifics (mileage, serial number) and info that can't be answered with a yes/no, where as features is a list of standard features found on aircraft that each listing may or may not have (air conditioning, etc).
First question is, would it be best to include the primary key id of the master table (core table) and include that in every sub-table, or include the id's of the subtables in the master table. I'm thinking it would be best to include the record id's of the subtables as columns in the master table. That way when you hit the master table, you are given the exact id of the records of all other related tables. (this would provide for a precise "seek" in the subtables searches for related records). The other way, you would have to search the subtables for records that match the master record ID every time. You couldn't just seek.
Granted, I'm still working on adding features/columns, so I'm not asking for advice on what data I'm collecting about aircraft. Just advice on the general structure and how I'm seperating the data.
tbl_aircraft_classifieds_core
classified_id (int-identity-pk)
member_id (int-fk)
category_id (int-fk)
details_id (int-fk)
features_id (int-fk)
title (nvarchar-45)
shortline_a (nvarchar-25)
shortline_b (nvarchar-25)
shortline_c (nvarchar-25-null)
quantity (int)
currency (varchar-30)
price (decimal-9/2-null)
year (smallint-null)
make (nvarchar-25)
model (nvarchar-35-null)
show_thumbnail (bit)
thumbnail_url (varchar-255-null)
address_a (int)
db_list (bit)
created (datetime)
created_ip (varchar-16)
last_modified (datetime-null)
last_modified_ip (varchar-16-null)
status (varchar-15)
tbl_aircraft_classifieds_categories
category_id (int-identity-pk)
category_parent_a (varchar-35)
category_child_a (varchar-35)
category_parent_b (varchar-35-null)
category_child_b (varchar-35-null)
category_parent_c (varchar-35-null)
category_child_c (varchar-35-null)
tbl_aircraft_classifieds_details
details_id (int-identity-pk)
condition (varchar-20)
market_value (decimal-9/2-null)
warranty (bit)
registration (nvarchar-50-null)
serial_number (nvarchar-50-null)
total_time (nvarchar-35-null)
overhaul (nvarchar-35-null)
flight_rules (varchar-30-null)
inspection_status (varchar-30-null)
airframe (varchar-30-null)
props (smallint-null)
avionics_radios (nvarchar-50-null)
color (varchar-30-null)
seats (varchar-8-null)
doors (varchar-30-null)
engine (nvarchar-25-null)
tbl_aircraft_classifieds_features
features_id (int-identity-pk)
air_conditioning (bit)
am_fm_stereo (bit)
cassette (bit)
single_cd (bit)
multi_cd (bit)
premium_sound (bit)
dvd (bit)
leather (bit)
power_seat (bit)
dual_power_seats (bit)
I'm working on a simple aircraft classified ad application. I'm designing the main tables for the classified ads. The initial app was written with everything in one big table, but I'm trying to simplify it down into several smaller tables. (normalization)
-Core (main data)
-categories
-details
-features
Core is the main table. This includes the essential information (title, id of member who listed ad) and is going to be the core table to be included in search results. Basically, when someone is browsing listings, the core table includes the data that is included for the ad in each listing.
Categories is self explanatory. This table includes the categories that are bound to the ad.
The difference between details and features is that the details table will include data that requires custom entry about specifics (mileage, serial number) and info that can't be answered with a yes/no, where as features is a list of standard features found on aircraft that each listing may or may not have (air conditioning, etc).
First question is, would it be best to include the primary key id of the master table (core table) and include that in every sub-table, or include the id's of the subtables in the master table. I'm thinking it would be best to include the record id's of the subtables as columns in the master table. That way when you hit the master table, you are given the exact id of the records of all other related tables. (this would provide for a precise "seek" in the subtables searches for related records). The other way, you would have to search the subtables for records that match the master record ID every time. You couldn't just seek.
Granted, I'm still working on adding features/columns, so I'm not asking for advice on what data I'm collecting about aircraft. Just advice on the general structure and how I'm seperating the data.
tbl_aircraft_classifieds_core
classified_id (int-identity-pk)
member_id (int-fk)
category_id (int-fk)
details_id (int-fk)
features_id (int-fk)
title (nvarchar-45)
shortline_a (nvarchar-25)
shortline_b (nvarchar-25)
shortline_c (nvarchar-25-null)
quantity (int)
currency (varchar-30)
price (decimal-9/2-null)
year (smallint-null)
make (nvarchar-25)
model (nvarchar-35-null)
show_thumbnail (bit)
thumbnail_url (varchar-255-null)
address_a (int)
db_list (bit)
created (datetime)
created_ip (varchar-16)
last_modified (datetime-null)
last_modified_ip (varchar-16-null)
status (varchar-15)
tbl_aircraft_classifieds_categories
category_id (int-identity-pk)
category_parent_a (varchar-35)
category_child_a (varchar-35)
category_parent_b (varchar-35-null)
category_child_b (varchar-35-null)
category_parent_c (varchar-35-null)
category_child_c (varchar-35-null)
tbl_aircraft_classifieds_details
details_id (int-identity-pk)
condition (varchar-20)
market_value (decimal-9/2-null)
warranty (bit)
registration (nvarchar-50-null)
serial_number (nvarchar-50-null)
total_time (nvarchar-35-null)
overhaul (nvarchar-35-null)
flight_rules (varchar-30-null)
inspection_status (varchar-30-null)
airframe (varchar-30-null)
props (smallint-null)
avionics_radios (nvarchar-50-null)
color (varchar-30-null)
seats (varchar-8-null)
doors (varchar-30-null)
engine (nvarchar-25-null)
tbl_aircraft_classifieds_features
features_id (int-identity-pk)
air_conditioning (bit)
am_fm_stereo (bit)
cassette (bit)
single_cd (bit)
multi_cd (bit)
premium_sound (bit)
dvd (bit)
leather (bit)
power_seat (bit)
dual_power_seats (bit)