Dbms A5 - Merged
Dbms A5 - Merged
1. Create tables for Client, Product, and Salesman with the attributes given, implementing DDL
commands for specifying prime attributes, non-prime attributes, foreign keys, cardinalities, null
values, constraints etc. and the data types. Implement DDL commands for drop, alter on the tables
created.
2. Implement DML commands like populating the tables with data using insert command and
retrieving data using simple queries in SQL. (Application of select, update, delete etc.)
CLIENT_MASTER
DESC CLIENT_MASTER;
PRODUCT_MASTER
DESC PRODUCT_MASTER;
SALESMAN_MASTER
CREATE TABLE SALESMAN_MASTER(Salesman_no VARCHAR2(6) CHECK(Salesman_no
LIKE 'S%') PRIMARY KEY,
Salesman_name VARCHAR2(20) NOT NULL,
City VARCHAR(20) NOT NULL,
Pincode NUMBER(8) NOT NULL,
State VARCHAR(20) NOT NULL,
Sal_Amt NUMBER(8,2) CHECK(Sal_Amt>0) NOT NULL);
DESC SALESMAN_MASTER;
SALES_ORDER
CREATE TABLE SALES_ORDER(Order_no VARCHAR2(6) CHECK(Order_no LIKE 'O%')
PRIMARY KEY,
Client_no VARCHAR2(6) REFERENCES CLIENT_MASTER(Client_no) ON DELETE
CASCADE,
Order_date DATE,
Salesman_no VARCHAR2(6) REFERENCES SALESMAN_MASTER(Salesman_no) ON
DELETE CASCADE,
Dely_type char(1) default 'F' CHECK(Dely_type='P' OR Dely_type='F'),
Dely_date DATE);
DESC SALES_ORDER;
SALES_ORDER_DETAILS
CREATE TABLE SALES_ORDER_DETAILS(Order_no VARCHAR2(6) REFERENCES
SALES_ORDER(Order_no) ON DELETE CASCADE,
Product_no VARCHAR2(6) REFERENCES PRODUCT_MASTER(Product_no) ON DELETE
CASCADE,
Qty_disp NUMBER(8),
Product_rate NUMBER(10,2)
);
DESC SALES_ORDER_DETAILS;
CLIENT_MASTER
SALESMAN_MASTER
SALES_ORDER_DETAILS
v. Add a column called ‘Telephone’ of data type number and size = 10 to the Client_Master table.
ix. Delete all products from Product_Master where the quantity on hand is equal to 90.
x. Delete from Client_Master where the column state holds the value ‘Maharashtra’.
1. List the names of all clients having ‘A’ as the third letter in their names.
Query: SELECT NAME FROM CLIENT_MASTER WHERE NAME LIKE '__a%';
2. List the clients who stay in a city whose first letter is ‘K’
Query: SELECT *FROM CLIENT_MASTER WHERE CITY LIKE '%K%';
5. List all information from the Sales_Order table for orders placed in the month of June.
Query: SELECT *FROM SALES_ORDER WHERE ORDER_DATE LIKE '%-06-%';
7. List products whose selling price is greater than 500 and less than or equal to 750.
Query: SELECT *FROM PRODUCT_MASTER WHERE SELL_PRICE>500 AND
SELL_PRICE<=750;
8. Count the total number of order.
Query: SELECT COUNT(ORDER_NO) FROM SALES_ORDER_DETAILS;
9. Determine the maximum and minimum product prices. Rename the output as max_price and
min_price respectively.
Query: SELECT MIN(SELL_PRICE) “MIN_PRICE”, MAX(SELL_PRICE) “MAX_PRICE”
FROM PRODUCT_MASTER;
11. Count the number of products having price less than or equal to 500.
Query: SELECT COUNT(PRODUCT_NO) FROM PRODUCT_MASTER WHERE
COST_PRICE<=500;
12. List the order number and day on which clients placed their order.
Query: SELECT ORDER_NO, TO_CHAR(TO_DATE(ORDER_DATE,'DD-MM-YY'),'Month')
AS MONTHNAME FROM SALES_ORDER;
16. Find the difference between maximum BalDue and minimum BalDue.
Query: SELECT MAX(BALDUE)-MIN(BALDUE) FROM CLIENT_MASTER;
Employee:
DESC Employee;
Company:
DESC Company;
Works:
DESC Works;
Employee:
INSERT INTO Employee VALUES('E00001','Ankush','12-10-2002','M','Kanchrapara',15000);
INSERT INTO Employee VALUES('E00002','Asha','22-10-2012','F','Kalyani',25000);
INSERT INTO Employee VALUES('E00003','Ronaldo','12-09-2003','M','Saltlake',20000);
INSERT INTO Employee VALUES('E00004','Rocky','29-03-2015','M','Esplanade',35000);
INSERT INTO Employee VALUES('E00005','Sneha','21-06-1999','F','Barrackpore',55000);
COMMIT;
Company:
INSERT INTO Company VALUES('C00001','Clifford Corp','Kolkata');
INSERT INTO Company VALUES('C00002','Edmond Corp','Mumbai');
INSERT INTO Company VALUES('C00003','Wipro','Bengalore');
INSERT INTO Company VALUES('C00004','TCS','Bengalore');
INSERT INTO Company VALUES('C00005','Mahindra','Kolkata');
COMMIT;
Works:
Query: SELECT Name FROM Employee WHERE DOB BETWEEN '01-01-1999' AND '31-12-
2011';
Software Requirements
Specification
for
Online Library
Management System
Version 1.0 approved
Prepared by Ankush Poddar
16.09.2024
1 | Page
Contents
1 Functional Requirements ..........................................................................................................3
1.1 Greetings............................................................................................................................3
1.2 User Authentication ...........................................................................................................3
1.2.1 Username and Password Verification ........................................................................3
1.2.2 Forgot Password .........................................................................................................3
1.3 Book Management .............................................................................................................3
1.3.1 Search for Books ........................................................................................................3
1.3.2 Book Reservation .......................................................................................................4
1.3.3 Book Checkout ...........................................................................................................4
1.3.4 Book Return ...............................................................................................................4
1.3.5 View Borrowed Books ...............................................................................................4
1.3.6 Fine Payment ..............................................................................................................4
1.3.7 Update Personal Information......................................................................................4
1.3.8 Book Recommendation ..............................................................................................5
1.3.9 Review and Rate Books .............................................................................................5
2 | Page
1 Functional Requirements
1.1 Greetings
• Description: A greeting message appears on the screen when a user accesses the online
library management system, acknowledging the user’s access.
• Output: Welcome message with the name and logo of the library.
• Error: System temporarily out of service.
• Description: The user enters a username and password to log in to the system.
• Input: User needs to input their username and password in the designated fields.
• Output: Verified successfully, user gains access to the system.
• Error: Invalid username or password, account locked after multiple failed attempts.
• Description: The user requests to reset the password by providing their registered email
or phone number.
• Input: User needs to input the registered email or phone number.
• Output: Password reset link sent to the email or OTP sent to the phone.
• Error: Invalid email or phone number.
• Description: The user searches for books available in the library's catalog.
• Input: User enters the book title, author name, ISBN, or keywords in the search bar.
• Output: A list of books matching the search criteria is displayed.
• Error: No books found matching the search criteria.
3 | Page
1.3.2 Book Reservation
• Description: The user wants to reserve a book that is currently checked out by another
user.
• Input: User selects the book they wish to reserve.
• Output: Reservation confirmation is displayed, and an email notification is sent.
• Error: Book already reserved by another user.
• Description: The user wants to check out a book from the library.
• Input: User selects the book for checkout and confirms the action.
• Output: Checkout confirmation is displayed, and due date information is provided.
• Error: Book unavailable or user's account has overdue books.
• Description: The user wants to view a list of all books currently borrowed.
• Input: No input required beyond logging into the system.
• Output: A list of borrowed books with due dates is displayed.
• Error: No books currently borrowed.
• Description: The user pays any overdue fines through the online system.
• Input: User selects the option to pay fines and enters payment details.
• Output: Payment confirmation is displayed, and an email receipt is sent.
• Error: Invalid payment information, or payment gateway error.
• Description: The user updates their personal information, such as address, phone
number, or email.
• Input: User enters the new information in the appropriate fields.
• Output: Confirmation of successful update.
• Error: Invalid input or system error.
4 | Page
1.3.8 Book Recommendation
• Description: The user can recommend books for the library to acquire.
• Input: User enters book details (title, author, ISBN) and submits a recommendation.
• Output: Confirmation message of the recommendation being submitted.
• Error: Recommendation could not be submitted due to system error.
• Description: The user can review and rate books they have read.
• Input: User selects the book, enters a review, and assigns a rating.
• Output: Review and rating are successfully posted on the book's page.
• Error: Review could not be posted due to system error.
5 | Page
DFD Level 0 for the Online Library Management System
DFD Level 0 for the ATM System
UDP MULTI-CLIENT
Q. WAP to implement UDP mult-iclient in C. Every client will send some word to server and the
server will return the corresponding cipher text. Clients will print the cipher text.
Client:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>
#define PORT 8080
#define BUF_SIZE 1024
int main() {
int sockfd;
struct sockaddr_in servaddr;
char buffer[BUF_SIZE];
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
perror("Socket creation failed");
exit(EXIT_FAILURE);
}
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = inet_addr("127.0.0.1");
servaddr.sin_port = htons(PORT);
while (1) {
printf("Enter a word to send to the server: ");
fgets(buffer, BUF_SIZE, stdin);
buffer[strcspn(buffer, "\n")] = 0;
Server:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>
#define PORT 8080
#define BUF_SIZE 1024
void caesar_cipher(char *text, int shift) {
for (int i = 0; text[i] != '\0'; i++) {
char c = text[i];
if (c >= 'a' && c <= 'z') {
text[i] = (c - 'a' + shift) % 26 + 'a';
} else if (c >= 'A' && c <= 'Z') {
text[i] = (c - 'A' + shift) % 26 + 'A';
}
}
}
int main() {
int sockfd;
struct sockaddr_in servaddr, cliaddr;
char buffer[BUF_SIZE];
socklen_t len;