1 / 13

C++ とオブジェクトデータベース入門

C++ とオブジェクトデータベース入門. 8.オブジェクトデータベースとは 森井 喬. Web ページ http:// www.db.is.kyushu-u.ac.jp/fish/rinkou /. オブジェクトデータベース(ODB). オブジェクト指向プログラミング言語とデータベースを統合したもの データの集合を、手続きとデータを一体化したオブジェクトの集合として扱う. ODBの利点. SQL などの DB 操作言語を必要とせず、開発で用いた言語( C++ 等)でデータベースを操作できる SQLでデータベースを操作することもできる

tia
Télécharger la présentation

C++ とオブジェクトデータベース入門

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C++とオブジェクトデータベース入門 8.オブジェクトデータベースとは 森井 喬 Webページ http://www.db.is.kyushu-u.ac.jp/fish/rinkou/

  2. オブジェクトデータベース(ODB) • オブジェクト指向プログラミング言語とデータベースを統合したもの • データの集合を、手続きとデータを一体化したオブジェクトの集合として扱う

  3. ODBの利点 • SQLなどのDB操作言語を必要とせず、開発で用いた言語( C++等)でデータベースを操作できる • SQLでデータベースを操作することもできる • オブジェクトモデルのテーブルへのマッピングが不要 • テーブルの属性同士の関係などをそのまま2次記憶装置に格納できる • スキーマの変更が容易に行うことができる

  4. ODBの欠点 • アプリケーション依存性が高い • ODBではクラスをそのままデータベースのスキーマとして利用するため、データのスキーマ(クラス)をあらかじめ知っておく必要がある

  5. ODBの用語 • クラス • RDBでのテーブル • インスタンス • RDBでの行 • データの1つ1つ • 属性 • RDBでの列 • 不定長の文字列,画像,音声などのマルチメディア情報も格納できる • BLOB(binary large objects)型

  6. メソッド メソッド データ クラス クラス クラス メッセージ メソッドに与える引数

  7. 自動車クラス 属性 属性 属性 メソッド メソッド メソッド 車種 重量 生産 販売 車種 重量 車種 重量 生産 販売 生産 販売 乗用車クラス トラッククラス 乗員数 載積量 受注 クラスとインヘリタンス 基底クラス 派生クラス インヘリタンス(継承)

  8. ODBの例 • 去年のデータベースの勉強会でJasmineで作った商品販売データベース

  9. クラスと属性 • Customerクラス • uid ユーザID • mail 電子メールアドレス • pass パスワード • Commodityクラス • cid 商品ID • cname 商品名 • price 単価 • quantity 在庫量 • Orderクラス • onum 注文番号 • uid ユーザID • cid 商品ID • num 注文数 • odate 注文日時 • send 発送完了フラグ

  10. メソッド • Customerクラス • Integer addcus(uid, mail, pass) ユーザを新たに登録する • Integer deletecus(uid) ユーザを削除する • Bag<Customer> printcus() ユーザの一覧を表示する • Commodityクラス • Integer addcom(cid, cname, price, quantity) 商品を新たに登録する • Integer deletecom(cid) 商品を削除する • Bag<Commodity> printcom() 商品の一覧を表示する • Integer addstock(cid,quantity) 在庫の数を増やす • Integer deletestock(cid,quantity) 在庫の数を減らす • Orderクラス • Integer addorder(onum, uid, cid, num) 注文を追加する • Integer deleteorder(onum) 注文を削除する • Bag<Order> printorder(uid) 注文の一覧を表示する • Integer sendorder(onum) 発送を完了の状態にする

  11. クラス(Customerクラス)の定義 defineClass Customer super:Composite description:"Class Customer" { instance: Integer uid unique: mandatory:; String mail; String pass; Integer addcus(Integer u,String m,String p); Integer deletecus(Integer u); Bag<Customer> printcus(); };

  12. メソッド(addcus)の定義 Transaction.start(); defineProcedure Integer Customer::instance:addcus(Integer u,String m,String p) language :"c" { $defaultCF moriiCF; $Customer.new(uid:= u,mail:= m,pass := p); $return(1); }; Transaction.end();

  13. インスタンス jasmine(moriiCF) > cos = co.printcom(); jasmine(moriiCF) > cos.print(); Bag{ moriiCF::Commodity::1 { cid = 1, cname = "database", price = 200, quantity = 10 }, moriiCF::Commodity::2 { cid = 2, cname = "c++", price = 100, quantity = 4 } } インスタンス

More Related