I am planning to design db for a website. We have different screens in our website. Each screen should have unique id and each screen will be of different type. Info related to screen should store in its type table. How Can i do that?
My plan is use screens table with below fields
Screens
screen_id
screen_type
screen_type_table_name
Home_screen
home_screen_id
screen_id
language
content1
content2
home_screen_field1
home_screen_field2
aboutus_screen
aboutus_screen_id
screen_id
language
content1
content2
about_us_field1
about_us_field2
Relation of the above two tables is 1 to many(screens table to type table). One screen may have many records in type table (in different languages).
Problems here is, I cannot query the data in single query. As I am storing the table name in the screens table.
Can anybody suggest best db design here?
[EDIT]
I cannot store the info in same table..
Reasons:
1) language constraint
2) I need to maintain revision of each content
3) Each screen of different type. So fields will be different for each type. No of fields vary for each type also.
4) I cannot serialize the data too (as I need search kind of facility)
Req
With Screen Id, I should be able to fetch the content in single query. Please give me some suggestions.
Thanks In advance
Thanks
Venu
Your Home_screen and Aboutus_screen tables are exactly the same. You could try it like this:
As you see there is a double Primary Key on the screens table and you keep track of the type of page by the Foreign key to the screen_types, if that’s necessary.