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_nameHome_screen
home_screen_id screen_id language content1 content2 home_screen_field1 home_screen_field2aboutus_screen
aboutus_screen_id screen_id language content1 content2 about_us_field1 about_us_field2Relation 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 a开发者_JS百科ble to fetch the content in single query. Please give me some suggestions. Thanks In advanceThanks
VenuYour Home_screen and Aboutus_screen tables are exactly the same. You could try it like this:
//screens\\
screen_id (PK)
language (PK)
type_id (FK)
content1
content2
//screen_types\\
screen_type_id (PK)
screen_type_name
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.
Why don't you keep all the screens in one table? You should do something like
Screens id, language, content1, content2, etc
Then just query the table when you want a page. I'm not sure why you have separated them as it is, is there a specific reason for that?
精彩评论