Skip to content

Commit 5a936a6

Browse files
Merge pull request #59 from Trivadis/56-plural-singular
Fixes #56 - plural vs. singular table/view names
2 parents e6e674b + 032e84b commit 5a936a6

File tree

7 files changed

+67
-5
lines changed

7 files changed

+67
-5
lines changed
12 KB
Binary file not shown.

docs/1-introduction/introduction.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,24 @@ Implementing formatting and coding standards has the following advantages for PL
6464
* The code is more efficient concerning performance and organization of the whole application.
6565
* The code is more modular and thus easier to use for other applications.
6666

67+
### We have other standards
68+
6769
This document only defines possible standards. These standards are not written in stone, but are meant as guidelines. If standards already exist, and they are different from those in this document, it makes no sense to change them.
6870

71+
### We do not agree with all your standards
72+
73+
There are basically two types of standards.
74+
75+
1. Non-controversial
76+
77+
These standards make sense. There is no reason not to follow them. An example of this category is [G-2150](../4-language-usage/2-variables-and-types/1-general/g-2150): Avoid comparisons with NULL value, consider using IS [NOT] NULL.
78+
79+
2. Controversial
80+
81+
Almost every rule/guildeline falls into this category. An example of this category is [3 space indention](../3-coding-style/coding-style/#rules). - Why not 2 or 4 or even 8? Why not use tabs? You can argue in favor of all these options. In most cases it does not really matter which option you choose. Being consistent is more important. In this case it will make the code easier to read.
82+
83+
For very controversial rules, we have started to include the reasoning either as a footnote or directly in the text.
84+
85+
Usually it is not helpful to open an issue on GitHub to request to change a highly controversial rule such as the one mentioned. For example, use 2 spaces instead of 3 spaces for an indentation. This leads to a discussion where the people in favor of 4 spaces start to argument as well. There is no right or wrong here. You just have to agree on a standard.
86+
87+
More effective is to fork [this repository](https://github.com/Trivadis/plsql-and-sql-coding-guidelines) and amend the standards fit your needs/expectations.

docs/2-naming-conventions/naming-conventions.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Examples:
5656

5757
### Column
5858

59-
Singular name of what is stored in the column (unless the column data type is a collection, in this case you use plural names)
59+
Singular name of what is stored in the column (unless the column data type is a collection, in this case you use plural[^1] names)
6060

6161
Add a comment to the database dictionary for every column.
6262

@@ -182,7 +182,7 @@ Examples:
182182

183183
### Table
184184

185-
Plural name of what is contained in the table (unless the table is designed to always hold one row only – then you should use a singular name)
185+
Plural[^1] name of what is contained in the table (unless the table is designed to always hold one row only – then you should use a singular name)
186186

187187
Add a comment to the database dictionary for every table and every column in the table.
188188

@@ -223,7 +223,7 @@ Examples:
223223

224224
### View
225225

226-
Plural name of what is contained in the view.
226+
Plural[^1] name of what is contained in the view.
227227
Optionally suffixed by an indicator identifying the object as a view (mostly used, when a 1:1 view layer lies above the table layer)
228228

229229
Add a comment to the database dictionary for every view and every column.
@@ -234,3 +234,11 @@ Examples:
234234

235235
* `active_orders`
236236
* `orders_v` - a view to the orders table
237+
238+
[^1]:
239+
We see a table and a views as a collection. A jar containing beans is labeled with "beans".
240+
In Java we call such collection also beans (`List<Bean> beans`) and name an entry bean
241+
(`for (Bean bean : beans) {...}`). An entry of a table is a row (singular) and a table can
242+
contain an unbounded number of rows (plural). This and the fact that the Oracle database uses
243+
the same concept for their tables and views lead to the decision to use the plural
244+
to name a table or view.

docs/3-coding-style/coding-style.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Rule | Description
88
:--: | -----------
99
1 | Keywords are written uppercase, names are written in lowercase.
10-
2 | 3 space indention.
10+
2 | 3 space indention[^2].
1111
3 | One command per line.
1212
4 | Keywords `LOOP`, `ELSE`, `ELSIF`, `END IF`, `WHEN` on a new line.
1313
5 | Commas in front of separated elements.
@@ -85,3 +85,13 @@ Check whether we passed a valid sql name
8585
</pre>
8686
*/
8787
```
88+
89+
[^2]:
90+
Tabs are not used because the indentation depends on the editor configuration.
91+
We want to ensure that the code looks the same, indepenent of the editor used.
92+
Hence, no tabs. But why not use 8 spaces? That's the traditional value for a tab.
93+
When writing a package function the code in the body has an indentation of 3.
94+
That's 24 characters as a starting point for the code. We think it's too much.
95+
Especially if we try to keep a line below 100 or 80 characters. Other good options
96+
would be 2 or 4 spaces. We settled for 3 spaces as a compromise.
97+
The indentation is still good visible, but does not use to much space.

docs/stylesheets/extra.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@
3636
display: none;
3737
}
3838

39+
/* disable header of footnotes */
40+
.footnote h1 {
41+
display: none;
42+
}
43+
44+
/* do not show link details in brackets content: " [" attr(href) "]" */
45+
.md-typeset a:after {
46+
display: none;
47+
}
48+
3949
/* disable scrollbar */
4050
.md-typeset__scrollwrap,
4151
.md-typeset table:not([class]),
@@ -65,6 +75,11 @@
6575
page-break-before: avoid;
6676
}
6777

78+
[id="we-do-not-agree-with-all-your-standards"],
79+
[id="column"],
80+
[id="sequence"],
81+
[id="temporary-table-global-temporary-table"],
82+
[id="code-commenting"],
6883
[id="variables-types"],
6984
[id="numeric-data-types"],
7085
[id="character-data-types"],

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ extra_javascript:
2323
markdown_extensions:
2424
- admonition
2525
- pymdownx.arithmatex
26+
- footnotes
2627

2728
extra:
2829
guideline_version: 3.4-SNAPSHOT

tools/run-in-container/genpdf.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ function create_cover() {
1919
function write_file(){
2020
FILE=$1
2121
echo "" >> ${TARGET_DIR}/docs/index.md
22-
sed -e 's/..\/image/image/g' ${DATA_DIR}/docs/${FILE} | sed -e 's/&#10008;/X/g' >> ${TARGET_DIR}/docs/index.md
22+
sed -e 's/..\/image/image/g' ${DATA_DIR}/docs/${FILE} | \
23+
sed -e 's|../4-language-usage/2-variables-and-types/1-general/g-2150|#g-2150-avoid-comparisons-with-null-value-consider-using-is-not-null|g' | \
24+
sed -e 's|../3-coding-style/coding-style/#rules|#rules|g' | \
25+
sed -e 's/&#10008;/X/g' >> ${TARGET_DIR}/docs/index.md
26+
}
27+
28+
function fix_footnote_links() {
29+
mv index.html index.ori.html
30+
sed -e 's/a class="footnote-ref"/a /g' index.ori.html > index.html
2331
}
2432

2533
function write_text(){
@@ -47,6 +55,7 @@ function convert_to_pdf(){
4755
cd ${TARGET_DIR}
4856
mkdocs build
4957
cd site
58+
fix_footnote_links
5059
wkhtmltopdf --javascript-delay 3000 \
5160
--outline-depth 6 \
5261
--outline \

0 commit comments

Comments
 (0)