Oracle 12c:用于维护修订的最佳模式设计

时间:2018-05-03 11:02:54

标签: sql database database-design oracle12c

我需要在我的项目中维护软件文档书籍的修订版。我有以下表格:

  1. 图书:book_id,book_name,book_category
  2. Book_revisions:Book_id(FK),book_revision_id,book_release_ID(FK),book_developer_id(FK),book_pages,no_of_days,book_start_date,book_finish_date,book_version,latest_flag
  3. book_Releases:release_id,release_name,release_date
  4. 用户:developer_id,developer_email,developer_name
  5. 发布日期是用于查找最新版本的日期。版本是自动递增的,并且对于版本是唯一的。如果版本是该版本的最新版本,则Latest_flag设置为Y.

    现在,当我尝试获取仅包含最新版本的图书清单时,这里是我使用的查询:

       select book_revision_id, book_id, book_release_ID, book_developer_id, book_pages, no_of_days, book_start_date, book_finish_date, book_version
        from book_revisions r 
        where latest_flag = 'Y'
        and release_id = (select r1.book_release_id from book_revisions r1
        left join book_releases a on a.release_id = r1.book_release_id
        where r1.book_id = r.book_id and r1.latest_flag='Y' and rownum=1
        order by rel.release_date desc)
        and latest_flag='Y'
    

    这似乎有效,但我试图找出这是最好的方法还是有一些标准来设计和查询这些修订要求的架构?

    根据其中一条评论添加样本数据: enter image description here

0 个答案:

没有答案