BottleTalk Database Design
Realm names ( such as realm: ) are essentially the same as table names.
The basic design for entities and relations should powerful and general enough to provide a good foundation for the design of the Semantastic database as well.
blog:
- date order
- date order by tag
- use previous for posting thread
slug/name | summary | content | date | previous
|
test-111-page | 'This is a blog page' | '= What This Blog Ids About = etc. ' | Apr 25 2015 | test-page-000
|
- Content includes two tags and two links. Link to wiki:MyTestPage is unresolved ( invokes add action ).
tag:
name | description | searchword
|
python | About Python subjects | python
|
needs-work | Items that need work | 'needs&work'
|
python-workflow | About Python workflows | python&workflow
|
workflow | About workflow subjects | workflow
|
wiki:
- hierarchy ( ex. ParentPage/SubPage/SubSubPage )
- reference resolution by breadth, then by depth
- Page#Anchor is an entity, roughly a section: sub-realm
- type/templates are literally templates
- Such as 'wiki' ( default ), or 'section' with substitutes for header levels where used, what else ?
name | summary | type/template | content | version | date
|
TestWikiPage111 | Test of a wiki page ... | | '= Wiki Page 1 Title = \n One never knows, do one ... \n etc.' | 1 | Apr 22 2015
|
OtherWikiPage222 | | | ' ... === Testing Python === \n Section name resolves to OtherWikiPage222#TestingPython \n etc. ' | 1 | Apr 26 2015
|
- Content has a tag, two links and and InfoBox.
link:
- simple link data, no name
- group by domain
- equiv. of About: page
- could be strictly internal, for backlinks
relation:
parent: | relation: | child: | context: | value/sequence
|
blog:test-111-page | tag: | tag:python | |
|
blog:test-111-page | tag: | tag:needs-work | section: | #ThingsToDo
|
blog:test-111-page | link: | link:2223 | section: | #Python
|
blog:test-111-page | link: | wiki:MyTestPage | section: | #Workflow
|
wiki:TestWikiPage111 | tag: | tag:workflow | |
|
wiki:TestWikiPage111 | link: | link:NameOfLink | section: | #TestingTheWiki
|
wiki:TestWikiPage111 | link: | wiki:OtherWikiPage222#TestingPython | section: | #UsingPython
|
wiki:TestWikiPage111 | include: | infobox:TheConcreteThingCorp | section: | #InfoAboutCompanies
|
tag:python | assoc: | tag:python-workflow | weight: | 8
|
tag:python | assoc: | tag:workflow | weight: | 4
|
relationdef:
name | inverse | context ( of parent ) | sequence type
|
tag | tag_for | |
|
link | backlink | section | #SectionName
|
include | included_by | section | #SectionName
|
assoc | assoc | weight | float
|
section | section_of | outline | outline level
|
Debated with self about section: relationship, solves problems with metatag: references. May avoid hassle of <<Section>> macro."
type:
- two way, parse or generate
- similar to macros ?
ConcreteThing | InfoBox | ???
|
Is infobox: a meta-type or equiv to a sub-domain: ?
typedef:
- Attributes and display type
name | attribute | display type | display seq.
|
ConcreteThing | name | String | 1
|
ConcreteThing | location | String | 2
|
ConcreteThing | web_site | URL | 3
|
ConcreteThing | comments | Wiki | 4
|
ConcreteThing | wiki_page | WikiPath | 5
|
value:
- load system values from config file or config: realm ?
- All values are strings ( json )
name ( or db id ? ) | type: | value
|
value:3223 | String | This is a test.
|
value:LocalSiteName | String | Wickedest Wiki Around
|
TheConcreteThingCorp | ConcreteThing | { name: 'CCTC', location: 'Palo Alto', web_site: http://cctc.com, wiki_page: 'SomePage#ConcreteThing' }
|
AboutKtty | Dict | { name='hello kitty', descr='This is kitty\'s big day', url='http://shesabeast.com/my-little-kitty.html'}
|
- Note that value:TheConcreteThingCorp is a singleton object of type:ConcreteThing.
- Dict->OrderedDict maintains display order ... still vague on details.
Python Functions, Adapters, Converters And Collations
Very useful capability.
Built in sqlite functions, for ex.
select replace(child,'tag:',''), replace(parent,'home:','') from tagrelation
where relation = 'tag' and parent like 'home:%'
order by child
Can also use Python functions. for ex.
import sqlite3
import md5
def md5sum(t):
return md5.md5(t).hexdigest()
con = sqlite3.connect(":memory:")
con.create_function("md5", 1, md5sum)
cur = con.cursor()
cur.execute("select md5(?)", ("foo",))
print cur.fetchone()[0]
Function - https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.create_function
Aggregate - https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.create_aggregate
Collation - https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.create_collation
Adapter - https://docs.python.org/2/library/sqlite3.html#using-adapters-to-store-additional-python-types-in-sqlite-databases
Converter - https://docs.python.org/2/library/sqlite3.html#converting-sqlite-values-to-custom-python-types
Also See
BottleTalk#Database for discussion of section: realm.