CreateBookmarksTableCommand is a command object whose execute method initializes the bookmarks table through DatabaseManager. It keeps table-creation work in the business logic layer while relying only on the persistence interface it needs. section 6.3.2
Its small implementation defines the bookmarks table with:
- An autogenerated integer primary key. section 6.3.2
- Required title, URL, and date_added text fields. section 6.3.2
- An optional notes field. section 6.3.2
Creating the table
db = DatabaseManager('bookmarks.db') class CreateBookmarksTableCommand: def execute(self): db.create_table('bookmarks', { 'id': 'integer primary key autoincrement', 'title': 'text not null', 'url': 'text not null', 'notes': 'text', 'date_added': 'text not null', }) section 6.3.2
The design illustrates separation of concerns: the command requests table creation without implementing persistence details. However, its database-specific name and startup wiring can make it span business, persistence, and presentation layers, creating tighter coupling. section 6.3.2 section 10.3
Use the multitier architecture figure to relate the command to business, persistence, and presentation responsibilities. section 10.3
