Presentation is loading. Please wait.

Presentation is loading. Please wait.

C++とオブジェクトデータベース入門 8.オブジェクトデータベースとは 森井 喬 Webページ

Similar presentations


Presentation on theme: "C++とオブジェクトデータベース入門 8.オブジェクトデータベースとは 森井 喬 Webページ"— Presentation transcript:

1 C++とオブジェクトデータベース入門 8.オブジェクトデータベースとは 森井 喬 Webページ
森井 喬 Webページ

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クラス Commodityクラス Orderクラス uid ユーザID mail 電子メールアドレス
pass パスワード Commodityクラス cid 商品ID cname 商品名 price 単価 quantity 在庫量 Orderクラス onum 注文番号 num 注文数 odate 注文日時 send 発送完了フラグ

10 メソッド Customerクラス Commodityクラス Orderクラス
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 } インスタンス


Download ppt "C++とオブジェクトデータベース入門 8.オブジェクトデータベースとは 森井 喬 Webページ"

Similar presentations


Ads by Google