osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Create multiple sqlite tables, many-to-many design


On Wed, 14 Aug 2019, MRAB wrote:

>> The actual code is different. htbl, ttbl, jtbl, etc. Too short?
>> 
> Definitely! :-)
>
> Another thing you might want to avoid is naming something with what it is, 
> e.g. "Trails_Table" (why not just "Trails").

Another reason to read Celko's 'SQL Programming Style.'

In the 1970s I was writing FORTRAN ecosystem models punched on 80-column
Hollerith cards using an IBM 029 keypunch. Everything was as short as
possible, especially variable names. There were two valuable lessons I
learned (in addition to marking a Sharpie pen line diagonally across the
card deck to make it easier to put back in sequence when the box was
dropped):

1. Make variable names fully descriptive.

2. Write many comments to explain what things are and why you're doing
things the way you are.

The reason is that within 6 months (or less) you will look at your schema
and code and have no idea what's going on or why you wrote it like that.

Table names are commonly written with initial uppercase letters; variables
in all lowercase. Leave CamelCase in the desert. Use underscores between
words, e.g., hike_id, trail_nbr, not hyphens.

And, you might not be the only person looking at the schema and code needing
to understand what's going on.

Rich