Dbms Batch 2
Dbms Batch 2
INSERT INTO Student (student_id, name, marks) VALUES (1, 'Alice', 85);
INSERT INTO Student (student_id, name, marks) VALUES (2, 'Bob', 45);
INSERT INTO Student (student_id, name, marks) VALUES (3, 'Charlie', 70);
b) Create a PL SQL program that uses the where clause to apply the
moderation strategy to those
>>>
DECLARE
CURSOR student_cursor IS
SELECT student_id FROM Student WHERE marks > 30;
student_record student_cursor%ROWTYPE;
BEGIN
FOR student_record IN student_cursor LOOP
UPDATE Student
SET marks = marks + 5
WHERE student_id = student_record.student_id;
END LOOP;
COMMIT;
END;
2. a) Create a set of tables for Bus reservation database, add foreign
key constraints and incorporate referential integrity.
>>>
CREATE TABLE Bus (
bus_id INT PRIMARY KEY,
bus_number VARCHAR(20) UNIQUE
);
9 a) Create and insert records in the student and course tables, and
then use various join operations to display the records.
>>>
-- Join query
SELECT s.name, c.course_name
FROM Student s
JOIN Enrollment e ON s.student_id = e.student_id
JOIN Course c ON e.course_id = c.course_id;
Usage:
BEGIN
DisplayDayName(1); -- Output: Day: Sunday
DisplayDayName(5); -- Output: Day: Thursday
END;
10 a) Create a DCL command that permits the user to perform
creates, insert, update, and delete operations and also not permitting
the particular user to perform delete operation.
>>>
1. Grant Permissions:
The XML Schema (XSD) defines the structure and data types for your XML documents. This
ensures that your XML data adheres to a consistent format.
voting_schema.xsd
xml
Copy code
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Root element -->
<xs:element name="Election">
<xs:complexType>
<xs:sequence>
<!-- Candidates section -->
<xs:element name="Candidates">
<xs:complexType>
<xs:sequence>
<xs:element name="Candidate"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="ID"
type="xs:integer"/>
<xs:element name="Name"
type="xs:string"/>
<xs:element name="Party"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
election_data.xml
xml
Copy code
<?xml version="1.0" encoding="UTF-8"?>
<Election xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="voting_schema.xsd">
<!-- Candidates information -->
<Candidates>
<Candidate>
<ID>1</ID>
<Name>John Doe</Name>
<Party>Democrat</Party>
</Candidate>
<Candidate>
<ID>2</ID>
<Name>Jane Smith</Name>
<Party>Republican</Party>
</Candidate>
</Candidates>
To query the XML data, you can use XPath or XQuery. Here’s an example XPath query to
retrieve the number of votes for a candidate:
xpath
Copy code
/Election/Results/Result[CandidateID=1]/VotesCount
Let’s assume you have a larger database with tables for employees and departments.
sql
Copy code
-- Create tables
CREATE TABLE departments (
department_id SERIAL PRIMARY KEY,
department_name VARCHAR(100) NOT NULL
);
2. Execute a Transaction:
Consider a scenario where you want to update salaries and add new employees within a single
transaction:
sql
Copy code
BEGIN;
-- Update salary
UPDATE employees
SET salary = salary * 1.05
WHERE department_id = 1;
3. Rollback Example:
sql
Copy code
BEGIN;
-- Make changes
UPDATE employees
SET salary = salary * 1.05
WHERE department_id = 1;
TCL Commands:
bash
Copy code
db.votes.insertMany([
{ "voter_id": "voter123", "candidate_id": 1 },
{ "voter_id": "voter124", "candidate_id": 2 }
]);
b. Query Documents:
bash
Copy code
db.votes.find({ "candidate_id": 1 })
cql
Copy code
-- Use keyspace
USE voting_db;
-- Create table
CREATE TABLE candidates (
candidate_id INT PRIMARY KEY,
name TEXT,
party TEXT
);
-- Insert data
INSERT INTO candidates (candidate_id, name, party) VALUES (1, 'John Doe',
'Democrat');
INSERT INTO votes (voter_id, candidate_id) VALUES ('voter123', 1);
b. Query Data:
cql
Copy code
cypher
Copy code
// Create nodes
CREATE (john:Candidate {name: 'John Doe', party: 'Democrat'})
CREATE (jane:Candidate {name: 'Jane Smith', party: 'Republican'})
CREATE (alice:Voter {name: 'Alice'})
// Create relationships
CREATE (alice)-[:VOTES_FOR]->(john);
cypher
Copy code
MATCH (voter:Voter)-[:VOTES_FOR]->(candidate:Candidate)
RETURN voter.name, candidate.name;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
@Override
public void start(Stage primaryStage) {
// Create UI components
Label studentLabel = new Label("Student Name:");
TextField studentNameField = new TextField();
>>>
13. Software for Purchase Monitoring System
For a purchase monitoring system, you can create a basic web application or desktop app. Here’s
a conceptual approach:
a. Define Requirements:
You can use frameworks like Spring Boot for web applications or JavaFX for desktop. Here’s a
simplified version:
Database Design:
o Tables for Products, Purchases
CRUD Operations: Create, Read, Update, Delete products and purchases
Dashboard: View purchase summaries, trends, etc.
function JewelryShop() {
const [items, setItems] = useState([]);
const addItem = (item) => {
setItems([...items, item]);
};
return (
<div>
<h1>Jewelry Shop</h1>
<button onClick={() => addItem({ name: 'Necklace', price: 100 })}>Add
Necklace</button>
<ul>
{items.map((item, index) => (
<li key={index}>{item.name} - ${item.price}</li>
))}
</ul>
</div>
);
}
javascript
Copy code
function CertificateApplication() {
const [formData, setFormData] = useState({
name: '',
certificateType: 'income',
documents: null
});
return (
<form onSubmit={handleSubmit}>
<label>Name:</label>
<input type="text" value={formData.name} onChange={(e) =>
setFormData({ ...formData, name: e.target.value })} required />
<label>Certificate Type:</label>
<select value={formData.certificateType} onChange={(e) =>
setFormData({ ...formData, certificateType: e.target.value })}>
<option value="income">Income Certificate</option>
<option value="community">Community Certificate</option>
</select>
<label>Upload Documents:</label>
<input type="file" onChange={(e) => setFormData({ ...formData,
documents: e.target.files[0] })} required />
<button type="submit">Apply</button>
</form>
);
}
javascript
Copy code
javascript
Copy code
function Booking() {
const [roomType, setRoomType] = useState('');
const [checkIn, setCheckIn] = useState('');
const [checkOut, setCheckOut] = useState('');
return (
<form onSubmit={handleSubmit}>
<label>Room Type:</label>
<input type="text" value={roomType} onChange={(e) =>
setRoomType(e.target.value)} required />
<label>Check-in Date:</label>
<input type="date" value={checkIn} onChange={(e) =>
setCheckIn(e.target.value)} required />
<label>Check-out Date:</label>
<input type="date" value={checkOut} onChange={(e) =>
setCheckOut(e.target.value)} required />
javascript
Copy code
app.use(express.json());
Requirements:
Technologies:
Example Workflow:
1. Property Management:
o CRUD operations for properties.
2. Tenant Management:
o Manage tenant details and leases.
3. Payment Tracking:
o Process and track payments.
4. Reporting:
o Generate reports on properties, payments, etc.
18 Create software for online auction system.
>>>>
Requirements:
Technologies:
Example Workflow:
1. Create Auctions:
o Allow users to create and manage auctions.
2. Bidding System:
o Users place bids, and highest bid wins.
3. User Management:
o Handle registration, login, and profiles.
4. Results Announcement:
o Notify users of auction results.
Requirements:
Technologies:
Example Workflow:
1. Inventory Management:
o Manage garment stock, categories, and suppliers.
2. Order Management:
o Process and track customer orders.
3. Supplier Management:
o Handle supplier details and orders.
4. Reporting:
o Generate sales and inventory reports.
Requirements:
Technologies:
Example Workflow:
1. Book Management:
o Add, edit, and manage book records.
2. User Management:
o Handle user registrations and borrowing privileges.
3. Borrowing System:
o Track borrowed books and due dates.
4. Reporting:
o Generate reports on book status, overdue items, etc.
Summary:
For each application, define your requirements and choose appropriate technologies.
Build frontend interfaces for user interaction.
Implement backend services to handle data and business logic.
Use databases to store and manage data.
If you need further details or specific examples for any of these applications, let me know!