【发布时间】:2016-02-14 14:26:40
【问题描述】:
我正在尝试学习如何使用名为 Eyedb(在 linux 上)的工具来创建面向对象的模型数据库。我已经为这个数据库制作了一些类和记录生成器,但我不知道如何使用 Java 编写查询代码。
数据库的结构如下:
class Lecturer {
attribute string<32> name;
attribute strin<32> surname;
relationship set <Lecture*> lectures inverse Lecture::Lecturer;
};
class Item{
attribute string<32> name;
attribute string<512> description;
};
class Topic extends Item {
relationship set<Lecture*> tlecture inverse Lecture::Topic;
};
class Lecture {
relationship Lecturer *llecturer inverse Lecturer::lectures;
relationship Topic *ltopic inverse Topic::tlecture;
relationship set <Content*> lcontent inverse Content::Lecture;
relationship set <Equipment*> lequipment inverse Content::Lecture;
relationship Room_timeslot* lroom_timeslot inverse Room_timeslot::rlecture;
};
class Content extends Item {
attribute int level;
relationship set <Content*> subcontent inverse Content::supcontent;
relationship set <Content*> supcontent inverse Content::subcontent;
relationship set <Teachingmaterial*> cteachingmaterial inverse Teachingmaterial::Content;
};
class Teachingmaterial extends Item {
attribute string link;
relationship set <Content*> tcontent inverse Content::Teachingmaterial;
};
class Equipment extends Item {
attribute int quantity;
attribute string symbol;
relationship set<Lecture*> electure inverse Lecture::Equipment;
relationship Room *eroom inverse Room::requipment;
};
class Room {
relationship set <Equipment*> requipment inverse Equipment::Room
attribute string name;
attribute int number;
attribute string symbol;
attribute string building;
attribute int floor;
attribute string wing;
relationship set <Room_timeslot*> rroom_timeslot inverse Room_timeslot::Room;
};
class Room_timeslot {
relationship Room *room inverse room::rroom_timeslot;
relationship Lecture* rlecture inverse Lecture::Room_timeslot;
relationship set <Timeslot*> rtimeslot inverse Timeslot::lroom_timeslot;
};
class Timeslot {
attribute string name;
attribute int number;
attribute time timemargin_start;
attribute time timemargin_end;
relationship set <Room_timeslot*> troom_timeslot inverse Room_timeslot::rtimeslot;
};
我想进行如下所示的查询:
SELECT lr.name as lecturer, t.name as topic FROM topic t
JOIN lecture l ON t.id_topic = l.id_topic
JOIN lecturer lr ON lr.id_lecturer = l.id_lecturer
ORDER BY lr.name
select t.name as topic from topic t
join lecture l on t.id_topic = l.id_topic
join lecturer lr on lr.id_lecturer = l.id_lecturer
where lr.name = "name1"
SELECT tm.name as teaching_material, e.name as equipment, lr.name as lecturer FROM teachingmaterial tm
JOIN teaching_content tc ON tc.id_teachingmaterial = tm.id_teachingmaterial
JOIN content c ON c.id_content = tc.id_content
JOIN content_lecture cl ON cl.id_content = c.id_content
JOIN lecture l ON l.id_lecture = cl.id_lecture
JOIN lecture_equipment le ON le.id_lecture = l.id_lecture
JOIN equipment e ON e.id_equipment = le.id_equipment
JOIN lecturer lr ON lr.id_lecturer = l.id_lecturer
【问题讨论】:
-
这不是学习学校或教学中心。在这里您可以获得技术问题的帮助。
标签: java sql object-oriented-database