Entry
TSE: Database: Edit: How to use TSE to edit your (master) databases?
Aug 7th, 2005 10:17
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 23 October 2004 - 04:21 pm --------------------
TSE: Database: Edit: How to use TSE to edit your (master) databases?
---
As you can use your TSE text editor for say up to 90% of your
activities on your computer (as text editing is the most frequent task
for most), editing database tables via TSE might be one of them.
---
You can e.g. create text databases like the following, and store them
in .txt files. This are then your master databases, which are the only
you edit. So all the editing takes places once and in a central place.
Then all the other database formats you need are generated from it.
--- cut here: begin ----------------------------------------------
------------------------------------------------------------------
DATABASE: DATABASENAME: <DATABASENAME>
------------------------------------------------------------------
TABLE: TABLENAME: <TABLENAME>
------------------------------------------------------------------
TABLE: TYPE: ONE TO ONE / ONE TO MANY / MANY TO ONE / MANY TO MANY
------------------------------------------------------------------
| NR | HEADER2 |
------------------------------------------------------------------
INTEGER( 4 ) STRING( 40 )
------------------------------------------------------------------
1 test
2 test
... ...
------------------------------------------------------------------
--- cut here: end ----------------------------------------------------
You could then e.g. mark this block here to create a template for it
(e.g. with the name 'table' using the template.mac macro (located in
your TSE mac directory), so when you type 'table' and with the cursor
after it pressing the 'tab' key it will be expanded in your text.
Then you convert this text database tables to the format convenient for
you,
e.g.
JavaScript array,
Java array,
CSV,
C# array,
SQL,
XML,
HTML
...
To convert you can one by one mark the columns of this table, get this
columns and then row after row of that column converting it (usually by
concatenating some extra strings before and after the text of each
column line).
===
You might use more and more the table (that is a rectangular structure
with rows and columns containing only the raw data)
This because incredible much real life data can easily and convenient
be represented in such a table structure, and simpler than this is
not really possible. It is really the minimum information.
If you put your data in such a rectangular structure, by searching
for the markers (e.g. '|' and '----') you can rather easily convert
it in other structures
1. e.g. conversion
table <-> comma separated values
table <-> XML
table <-> JavaScript array
table <-> SQL table
table <-> HTML table
You keep thus your 'mother of all mothers' data in 1 central
ASCII file (thus according to the often used variation of the
principle of 'only edit your data in one place').
You edit this data in the table with TSE.
And if necessary convert it (automatically using TSE macros)
---
FOR first TO last row of your table
FOR first TO last column of that row
// do something
ENDFOR
ENDFOR
---
in combination with string concatenation
to other formats like
---
XML
<TABLE>
<RECORD>
<COLUMN> ... </COLUMN>
<COLUMN> ... </COLUMN>
...
<COLUMN> ... </COLUMN>
</RECORD>
...
</TABLE>
---
CSV
column11, column12, ..., column1N
column21, column22, ..., column2N
...
columnM1, columnM2, ..., columnMN
---
JavaScript
<SELECT> lists which read their data from arrays
var test = new Array (
["<row1 column1>"],
["<row2 column1>"],
["<row3 column1>"],
...
["<rowN column1>"],
)
---
SQL
CREATE table <your tablename>
INSERT INTO
<mytable>
(
<columnname1>,
<columnname2>,
<columnname3>,
...
<columnnameN>
)
VALUES
(
<value1>,
<value2>,
<value3>,
...
<valueN>
)
;
---
HTML
<TABLE>
<TR>
<TH> columnname1 </TH>
<TH> columnname2 </TH>
...
<TH> columnnamelast </TH>
</TR>
<TR>
<TD> row1 column1 </TD>
<TD> row1 column2 </TD>
...
<TD> row1 columnN </TD>
</TR>
<TR>
<TD> row2 column1 </TD>
<TD> row2 column2 </TD>
...
<TD> row2 columnN </TD>
</TR>
...
<TR>
<TD> rowM column1 </TD>
<TD> rowM column2 </TD>
...
<TD> rowM columnN </TD>
</TR>
</TABLE>
---
---
Note:
This method will work best for e.g. read only and or static databases,
(e.g. maintained by 1 or a few persons) as the data has then not to be
changed on the fly dynamically and instantaneous.
Typical examples are product overviews, book databases, ...
---
---
Internet: see also:
---
TSE: Database: Link: Overview: Can you give an overview of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/32028/fid/1721
----------------------------------------------------------------------