the main table:
Id, Name
1, white snow neutral pen
2, the morning neutral pen
3, desk
Table 4,
5, tea table table
I want to show different users when they browse columns:
neutral pen:
Id, Name, Length, Color, (behind the user can also add other columns)
1, white snow neutral pen, 10, red
2, the morning neutral pen, 11, blue
table:
Id, Name, Height, Width, Length, Weight, behind (the user can also add other columns)
3, desk, 70, 40, 60, 4
4, table, 65, 40, 60, 6
5, table, tea table, 40, 30, 40, 2
Because category will be very much, each child table columns will be a lot of, also will often change, so can't fixed in the main table column name,
So how to design the database can display, and can not influence the efficiency of the query (such as screen time)?
I can think of is to add a "property sheet" :
Object_Id, Property, Value
1, Length, 10
1, Color, red
.
But don't know how to efficient query, after 1 million rows of data, the query, I wrote three to five attributes columns, check 1000 lines there will be more than 40 seconds before check out time:
Select Id, Name, GetPropertyValue (Id, "Length") as Length,... From the main table
- GetPropertyValue is a function of writing your own
At the same time, there are such problems as how to deal with different data type,
Thank you!