Conversation with Merlin [email protected] · Sat Nov 04 2023

Create data dictionary and create table query of oracle of library management system.

min 5 table

To create a data dictionary and sample table queries for a library management system in Oracle, we can consider the following five tables:

  1. Books table:
    • book_id (primary key)
    • title
    • author
  • publication
    • category_id (foreign key to Categories table)
  1. Members table:

    • member_id (primary key)
    • name
    • email
    • phone_number
  2. Categories table:

  • category_id (primary key)
    • category_name
  1. Borrowings table:

    • borrowing_id (primary key)
    • book_id (foreign key to Books table)
    • member_id (foreign key to Members table)
    • borrow_date
    • return_date
  2. Reservations table:

    • reservation_id (primary key)
    • book_id (foreign key to Books table)
    • member_id (foreign key to Members table)
    • reservation_date

Now, let's create the table queries for the above tables:

  1. Books table query:
CREATE TABLE ( book_id NUMBER PRIMARY KEY, title VARCHAR2(100), author VARCHAR2(100), publication_year NUMBER, category_id NUMBER, FOREIGN KEY (category_id) REFERENCES categories(category_id) );
  1. Members table query:
CREATE TABLE members ( member_id NUMBER PRIMARY KEY, name VARCHAR2(100), email VARCHAR2(100), phone_number VARCHAR2(20) );
  1. Categories table query:
CREATE TABLE categories ( category_id NUMBER PRIMARY KEY, category_name VARCHAR2(100) );
  1. Borrowings table query:
CREATE TABLE borrowings ( borrowing_id NUMBER PRIMARY KEY book_id NUMBER, member_id NUMBER, borrow_date DATE, return_date DATE, FOREIGN KEY (book_id) REFERENCES books(book_id), FOREIGN KEY (member_id) REFERENCES members(member_id) );
  1. Reservations table query:
CREATE TABLE reservations ( reservation_id NUMBER PRIMARY KEY, book_id NUMBER, member_id NUMBER, reservation_date DATE, FOREIGN KEY (book_id) REFERENCES books(book_id), FOREIGN KEY (member_id) REFERENCES members(member_id) );

These queries will create the necessary tables in the Oracle database for a library management system.

Create data dictionary and create table query of oracle of library management system.

min 5 table

Sure, let's create a simple data dictionary and tables for a library management system in Oracle that includes five tables: Books, Members, Categories, Borrowings, and Reservations.

Data Dictionary:

  1. Books :

    • book_id (Primary Key, Number): Unique identifier for each book.
    • title (Varchar2): Book's title.
    • author (Varchar2): Book's author.
    • publication_year (Number): Year of publication.
    • category_id (Foreign Key, Number): References to 'Categories' table.
  2. Members :

    • member_id (Primary Key, Number): Unique identifier for each member.
    • name (Varchar2): Member's name.
    • email (Varchar2): Member's email.
    • phone_number (Varchar2): Member's phone number.
  3. Categories :

    • category_id (Primary Key, Number): Unique identifier for each category.
    • category_name (Varchar2): Name of the category.
  4. Borrowings :

    • borrowing_id (Primary Key, Number): Unique identifier for each borrowing.
    • book_id (Foreign Key, Number): References to 'Books' table.
    • member_id (Foreign Key, Number): References to 'Members' table.
    • borrow_date (Date): Date when the book was borrowed.
    • return_date (Date): Date when the book is to be returned.
  5. Reservations :

    • reservation_id (Primary Key, Number): Unique identifier for each reservation.
    • book_id (Foreign Key, Number): References to 'Books' table.
    • member_id (Foreign Key, Number): References to 'Members' table.
    • reservation_date (Date): Date when the reservation was made.

Creation of Tables in Oracle:

  1. Books :
CREATE TABLE Books ( book_id NUMBER PRIMARY KEY, title VARCHAR2(100), author VARCHAR2(100), publication_year NUMBER, category_id NUMBER, FOREIGN KEY (category_id) REFERENCES Categories(category_id));
  1. Members :
CREATE TABLE Members ( member_id NUMBER PRIMARY KEY, name VARCHAR2(100), email VARCHAR2(100), phone_number VARCHAR2(20));
  1. Categories :
CREATE TABLE Categories ( category_id NUMBER PRIMARY KEY, category_name VARCHAR2(100));
  1. Borrowings :
CREATE TABLE Borrowings ( borrowing_id NUMBER PRIMARY KEY, book_id NUMBER, member_id NUMBER, borrow_date DATE, return_date DATE, FOREIGN KEY (book_id) REFERENCES Books(book_id), FOREIGN KEY (member_id) REFERENCES Members(member_id));
  1. Reservations :
CREATE TABLE Reservations ( reservation_id NUMBER PRIMARY KEY, book_id NUMBER, member_id NUMBER, reservation_date DATE, FOREIGN KEY (book_id) REFERENCES Books(book_id), FOREIGN KEY (member_id) REFERENCES Members(member_id));

Remember that you need to create the referenced table before you create tables that reference it. So the order to create the tables should be: Categories, Books, Members, Borrowings, Reservations.

Add Authors Table

Sure, let's add an 'Authors' table to the system.

Data Dictionary Addition:

Authors:

  • author_id (Primary Key, Number): Unique identifier for each author.
    • author_name (Varchar2): Name of the.

Creation of 'Authors' Table in Oracle:

CREATE TABLE Authors ( author_id NUMBER PRIMARY KEY, author_name VARCHAR2(100) );

With this addition, the Books table should be modified to have a foreign key that references the Authors table. The 'author' field in Books table will now be author_id to ensure data consistency.

**Modified Books Table:

Books :

  • book_id ( Key, Number): Unique identifier for each book.
  • title (Varchar2): Book's title.
  • author_id (Foreign Key, Number): ID of the book's author linked to Authors table.
  • publication_year (Number): Year of publication.
  • category_id (Foreign Key, Number): References to 'Categories' table.

Modification Query for Books Table in Oracle:

Please note that this will work only if the Books table is not created yet. If the Books table is already created, you would need to alter the table or recreate it.

CREATE TABLE Books ( book_id NUMBER PRIMARY KEY, title VARCHAR2(100), author_id NUMBER, publication_year NUMBER, category_id NUMBER, FOREIGN KEY (author_id) REFERENCES Authors(author_id), FOREIGN KEY (category_id) Categories(category_id) );

With this adjustment, we've included the 'Authors' table and established a relationship with the 'Books' table.