From fdc02cdfccd5b15ff70a0862ecd003fa065c1373 Mon Sep 17 00:00:00 2001 From: tirilane Date: Fri, 3 Jul 2009 16:09:14 +0000 Subject: [PATCH] Database: create-table --- db.lisp | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 db.lisp diff --git a/db.lisp b/db.lisp new file mode 100644 index 0000000..7ede259 --- /dev/null +++ b/db.lisp @@ -0,0 +1,87 @@ +(pushnew #P"/home/pvv/d/tirilane/clbuild/systems/" asdf:*central-registry*) +(asdf:oos 'asdf:load-op :postmodern) +(use-package :postmodern) + +(connect-toplevel "worblehat" "horace" "" "localhost") + +(:create-table book + ((isbn :type string :primary-key t) + (title :type string) + (year :type integer) + (publisher :type string) + (udc :type string) + (edition :type integer) + (picture :type string) + (description :type (or db-null text)) + (language :type string) + (review :type integer :unique t) + (author :type integer :unique t)) + (:foreign-key (review) (review id)) + (:foreign-key (author) (author id))) + +(:create-table review + ((id :type integer :primary-key t :references (book :cascade :cascade)) + (review :type text) + (grade :type integer) + (author :type string))) + +(:create-table author + ((id :type integer :primary-key t :references (book :cascade :cascade)) + (surname :type string) + (lastname :type string))) + +(:create-table copy + ((id :type integer :primary-key t) + (shelf :type string) + (rented :type boolean) + (owner :type string) + (condition :type string) + (book :type string)) + (:foreign-key (book) (book isbn))) + + +;(defclass book () +; ((isbn :col-type string +; :initarg :isbn +; :accessor book-isbn) +; (title :col-type string +; :initarg :title +; :accessor book-title) +; (year :col-type integer +; :initarg :year +; :accessor book-year) +; (publisher :col-type(or db-null string) +; :initarg :publisher +; :accessor book-publisher) +; (udc :col-type string +; :initarg udc +; :accessor book-udc) +; (edition :col-type integer +; :initarg :edition +; :accessor book-edition) +; (picture :col-type (or db-null string) +; :initarg :picture +; :accessor book-picture) +; (description :col-type (or db-null text) +; :initarg :description +; :accessor book-descripton) +; (language :col-type string +; :initarg :language +; :accessor book-language)) +; (:metaclass dao-class) +; (:keys name)) +; +;(defclass review () +; ((review :col-type text +; :initarg :review +; :accessor review-review) +; (grade :col-type integer +; :initarg :grade +; :accessor review-grade) +; (author :col-type text +; :initarg :author +; :accessor review-author)) +; (:metaclass dao-class) +; (:keys name)) + +