Project

General

Profile

Actions

Task #3147

closed

Draft database design and draft abstraction for GroupManagerDB

Added by Zhiyi Zhang over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Start date:
08/30/2015
Due date:
% Done:

100%

Estimated time:

Description

To manage members and schedules in GroupManager, we need a database to store these informations. GroupManagerDB is used to manage the database of GroupManager. GroupManagerDB uses SQLITE as the database.

Here is the draft database design :

 CREATE TABLE IF NOT EXISTS
   schedules(
     schedule_id         INTEGER PRIMARY KEY,
     schedule_name       TEXT NOT NULL,
     schedule            BLOB NOT NULL
   );
 CREATE UNIQUE INDEX IF NOT EXISTS
    scheduleNameIndex ON schedules(schedule_name);

 CREATE TABLE IF NOT EXISTS
   members(
     member_id           INTEGER PRIMARY KEY,
     schedule_id         INTEGER NOT NULL,
     member_name         BLOB NOT NULL,
     member_cert         BLOB NOT NULL,
     FOREIGN KEY(schedule_id)
       REFERENCES schedules(id)
       ON DELETE CASCADE
       ON UPDATE CASCADE
   );
 CREATE UNIQUE INDEX IF NOT EXISTS
    memNameIndex ON members(member_name);

Here is the daft abstraction of GroupManagerDB :

  class GroupManagerDB
  {
  public:
    class Error : public std::runtime_error
    {
    public:
      explicit
      Error(const std::string& what)
        : std::runtime_error(what)
      {
      }
    };

  public:
    explicit
    GroupManagerDB(const std::string dbDir);

  public:
    ////////////////////////////////////////////////////// schedule management

    /// @brief Check if there is a schedule by name @p name
    bool
    hasSchedule(const std::string& name) const;

    /// @brief List all the names of the schedules
    std::list<std::string>
    listAllScheduleNames() const;

    /// @brief Get schedule by name @p name
    Schedule
    getSchedule(const std::string& name) const;

    /// @brief Get member identities of a schedule named @p name
    std::list<Name>
    getScheduleMembers(const std::string& name) const;

    /// @brief Add a schedule @p schedule with the name @p name to DB
    bool
    addSchedule(const std::string& name, const Schedule& schedule);

    /// @brief Delete the schedule by name @p name
    bool
    deleteSchedule(const std::string& name);

    /// @brief Update the schedule name
    bool
    updateScheduleName(const std::string& old, const std::string& new);

    /// @brief Update the schedule by name @p name
    bool
    updateSchedule(const std::string& name, const Schedule& schedule);

    ////////////////////////////////////////////////////// member management

    /// @brief Check if there is a member by identity @p identity
    bool
    hasMember(const Name& identity) const;

    /// @brief List all the members
    std::list<Name>
    listAllMembers() const;

    /// @brief Get the certificate of the member by identity @p identity
    Data
    getMemberCert(const Name& identity) const;

    /// @brief Get the schedule name of the member
    std::string
    getMemberSchedule(const Name& identity) const;

    /// @brief Add a new member
    bool
    addMember(const std::string& scheduleName, const Data& certificate);

    /// @brief Update a member to change the schedule of this member
    bool
    updateMemberSchedule(const Name& identity, const std::string& schedule);

    /// @brief Delete a member from database
    bool
    deleteMember(const Name& identity)

  private:
    /// @brief Hide the database in the class Impl
    class Impl;
    unique_ptr<Impl> m_impl;
  };
Actions #1

Updated by Zhiyi Zhang over 8 years ago

  • Description updated (diff)
Actions #2

Updated by Zhiyi Zhang over 8 years ago

  • Description updated (diff)
Actions #3

Updated by Zhiyi Zhang over 8 years ago

  • Description updated (diff)
Actions #4

Updated by Zhiyi Zhang over 8 years ago

  • Description updated (diff)
Actions #5

Updated by Zhiyi Zhang over 8 years ago

  • Status changed from New to Code review
Actions #6

Updated by Zhiyi Zhang over 8 years ago

  • Status changed from Code review to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF