2010-06-14 49 views
0

我有一項家庭作業任務,需要使用Oracle 10g Express來實現對象關係數據庫來跟蹤電話帳單數據。我有Call類,Text類和Data類的通信超類。我正在填寫這些表格,以便我可以在各種表格中找到適當的數據。正確填充對象關係數據庫中的表格

我的類型和表被宣佈爲:

create type CommunicationType as object (
    -- column names here 
) not final; 
create type CallType under CommunicationType (
    -- column names here 
); 
create type TextType under CommunicationType (
    -- column names here 
); 
create type DataType under CommunicationType (
    -- column names here 
); 
create table Communications of CommunicationType (
    -- Primary and Foreign key constraints here 
); 
create table Calls of CallType; 
create table Texts of TextType; 
create table Datas of DataType; 

當我嘗試insert數據導入的一個子類,它的入口不超出現。同樣,如果我將這個insert放入超類中,它就不會顯示在適當的子類中。例如,insert into Calls values (CallType(-- Values --));在通訊中不顯示任何數據。 insert into Communications values (CallType(-- Values --));也不會在呼叫中顯示任何內容。

我在做什麼錯?

+1

有什麼不對?你正在考慮基於SET的世界中的OOP – 2010-06-14 18:48:25

+0

@OMG小馬:我相信你。 :)那麼,我是否誤解了我應該能夠從兩張表格中獲取信息,或者我可能會誤解*如何設置表格? – chaosTechnician 2010-06-14 19:03:22

回答

1

您已創建四個單獨的表。如果您將一行插入到一個表中,則沒有理由期望在另一個表中看到您的行。

你基於CallTypeTextTypeDataType表繼承他們從CommunicationType結構和行爲,但這並不意味着數據被複制。我懷疑你可能根本不需要表Communications

<一旁>個人而言,如果我使用的是Oracle數據庫我會放棄使用對象類型完全,只是使用純粹的關係模型進行建模的東西,但是這可能只是我 - 不幫你因爲你的老師似乎希望你實現一個「對象關係」數據庫...... :)

+0

如果要跳過「Communications」表,那麼我可以處理這個問題。那麼,需要3次查詢才能獲得有關所有通信(每個表一個)的信息? – chaosTechnician 2010-06-15 03:34:24

+0

您不需要3個查詢 - 單個查詢可以從多個表中提取數據,在這種情況下使用UNION。 – 2010-06-15 11:53:12

+0

好的。我會去那。謝謝! – chaosTechnician 2010-06-15 12:56:20