i’m new to sql, and am bulding a mysql and php application.
i might be planning the tables themselves wrong, and if so, would thank any ideas.
i have blocks contaning some columns, including title, text, slogan.
both title and text are more complex then seem, because i need font, size, and also approval on each of the texts. so i created a texts table with these columns.
these are the tables:
blocks
id(increment),text(texts.id),title(texts.id),slogan(texts.id),
type(enum),time(datetime),difficulty(int)
texts
id(increment),Text(text),font(varchar),size(int),approval(approval.id)
aprrovals
id(increment), User(varchar), time(datetime)
so here are the questions:
- is this a good way to hold this information? should i just have textxs hold the block id they belong to?
- how do i show a table contaning all columns of blocks, but showing the actual text from texts.Text instead of the ids?
- how do i select the approval.User of a specific text of a specifi block?
If I understand your question correctly, I don’t think it’s necessary to have the Approvals table. If a Text can have one and only one user approve it, and it can be approved on one and only one date, it’s unnecessary to separate Approvals.
I think that depends on your modeling needs. Is it always one text, one title and one slogan, and do all three have to be filled out? If so, it won’t matter if you do it like you’ve done now. However, if you’ll often see a block with just a text and no title and slogan, it might make more sense to make Texts reference Blocks.
Something like this should get you started: