0% found this document useful (0 votes)
4 views3 pages

Web

The document outlines a task for creating a library catalog using web technologies, focusing on SQL database design, management, and queries. It details the creation of tables for books and authors, SQL operations for altering tables, and user permissions. Additionally, it includes instructions for building an HTML form for book entry, implementing JavaScript validation, and writing a PHP script for data handling and display.

Uploaded by

neslybonkwe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Web

The document outlines a task for creating a library catalog using web technologies, focusing on SQL database design, management, and queries. It details the creation of tables for books and authors, SQL operations for altering tables, and user permissions. Additionally, it includes instructions for building an HTML form for book entry, implementing JavaScript validation, and writing a PHP script for data handling and display.

Uploaded by

neslybonkwe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Question 3: Web Technologies (Library Catalog)

• Concepts to Test: HTML Form, Connecting to Database with PHP, Inserting from Form to SQL Table,
Retrieving from Table and Display in HTML Table, Creating Landing Page using HTML5, JavaScript, and
CSS, SQL (creating tables, queries, insert, aggregate functions, joins, group by, altering tables, granting
user privileges, dropping tables)

• Task:

1. Database Design (SQL):

* Create a MySQL database (if you don't have one already).

* Create a MySQL database table called books with the following columns:

* bookID (INT, PRIMARY KEY, AUTO_INCREMENT)

* title (VARCHAR(255), NOT NULL)

* authorID (INT, NOT NULL)

* publicationYear (INT)

* isbn (VARCHAR(20))

* Create a MySQL database table called authors with the following columns:

* authorID (INT, PRIMARY KEY, AUTO_INCREMENT)

* authorName (VARCHAR(255), NOT NULL, UNIQUE)

* bio (TEXT)

* Add a FOREIGN KEY constraint on books.authorID referencing authors.authorID.

2. SQL Alteration and Management:

* Write SQL statements to:

* Rename the books table to library_books.

* Add a new column named coverImageURL (VARCHAR(255)) to the library_books table.

* Rename the column title to book_title in the library_books table.

* Remove the isbn column from the library_books table.


* Create a new user library_user with password secure_password who has SELECT access on the
library_books table and SELECT, INSERT access on the authors table.

* Revoke INSERT access from library_user on the authors table.

Drop the table authors. Note: This will fail until you remove the foreign key constraint that
references this table. You must remove that constraint first.*

3. SQL Queries:

* Write SQL queries to:

* Insert at least 5 sample authors into the authors table.

* Insert at least 5 sample books into the library_books table, referencing the authors.

* Retrieve all books and their authors (using a JOIN). Display the book title, author name, and
publication year.

* Calculate the number of books written by each author. Display the author's name and the book
count (using GROUP BY and COUNT).

* Find all books published after the year 2000.

* Find all books that contain the word "History" in the title (using LIKE).

* Find the average publication year of all books.

4. HTML Form (add_book.html): Create an HTML form that allows the user to enter the information for
a new book (title, publication year, select an author from a dropdown list, and optionally a cover image
URL). The author dropdown list should be dynamically populated from the authors table in the
database.

5. JavaScript Form Validation (add_book.html):

Implement JavaScript code to perform client-side form validation before* the form is submitted.
Validation should include:

* Checking that all required fields (title, author, publication year) are filled in.

* Checking that the publication year is a valid number.

* Display appropriate error messages to the user if the validation fails.

6. PHP Script (add_book.php):

* Create a PHP script that:


* Connects to the MySQL database.

* Retrieves the data submitted from the HTML form to sql table.

Display the data in an html table

Performs server-side validation* of the data, duplicating the checks done

You might also like