From 5043963095fd41e53b9dad465ac5b1d8bb96d4bf Mon Sep 17 00:00:00 2001 From: Kshitij Date: Thu, 25 Jul 2024 12:41:40 +0530 Subject: [PATCH] Moved Assignment-A2,A3 handout from handouts folder to Practical under the Assignment-A2,A3 folder respectively. Also added database queries for building Database_A2, need to add 'running queries'. Lastly, updated README. --- .../Assignment-A2/Handout-A2.pdf | Bin Practical/Assignment-A2/Queries-A2.md | 91 ++++++++++++++++++ .../Assignment-A3/Handout-A3.pdf | Bin README.md | 8 +- 4 files changed, 96 insertions(+), 3 deletions(-) rename Handouts/Assignment-A2.pdf => Practical/Assignment-A2/Handout-A2.pdf (100%) create mode 100755 Practical/Assignment-A2/Queries-A2.md rename Handouts/Assignment-A3.pdf => Practical/Assignment-A3/Handout-A3.pdf (100%) diff --git a/Handouts/Assignment-A2.pdf b/Practical/Assignment-A2/Handout-A2.pdf similarity index 100% rename from Handouts/Assignment-A2.pdf rename to Practical/Assignment-A2/Handout-A2.pdf diff --git a/Practical/Assignment-A2/Queries-A2.md b/Practical/Assignment-A2/Queries-A2.md new file mode 100755 index 0000000..a3887d3 --- /dev/null +++ b/Practical/Assignment-A2/Queries-A2.md @@ -0,0 +1,91 @@ +# Queries for Assignment-A2 + +This file contains all the queries required to build the [database](https://git.kska.io/DatabaseManagementSystems/src/branch/main/Practical/Assignment-A2/Database_A2.sql) + +## Creating database + +```sql +CREATE DATABASE Database_A2; +USE Database_A2; + +``` + +## Creating tables and specify primary keys: + +```sql +CREATE TABLE Account(accountNum INT, branchName VARCHAR(50), balance INT, PRIMARY KEY (accountNum)); +CREATE TABLE Branch(branchName VARCHAR(50), branchCity VARCHAR(50), assets INT, PRIMARY KEY (branchName)); +CREATE TABLE Customer (customerName VARCHAR(50), customerStreet VARCHAR(50), customerCity VARCHAR(50), PRIMARY KEY (customerName)); +CREATE TABLE Depositor (customerName VARCHAR(50), accountNum INT); +CREATE TABLE Loan (loanNum INT, branchName VARCHAR(50), amount INT, PRIMARY KEY (loanNum)); +CREATE TABLE Borrower (customerName VARCHAR(50), loanNum INT); + +``` + +## Altering tables to specify foreign keys + +```sql +ALTER TABLE Account ADD FOREIGN KEY (branchName) REFERENCES Branch(branchName); +ALTER TABLE Depositor ADD FOREIGN KEY (customerName) REFERENCES Customer (customerName); +ALTER TABLE Depositor ADD FOREIGN KEY (accountNum) REFERENCES Account (accountNum); +ALTER TABLE Loan ADD FOREIGN KEY (branchName) REFERENCES Branch (branchName); +ALTER TABLE Borrower ADD FOREIGN KEY (customerName) REFERENCES Customer (customerName); +ALTER TABLE Borrower ADD FOREIGN KEY (loanNum) REFERENCES Loan (loanNum); + +``` + +## Adding data + +```sql +INSERT INTO Branch (branchName, branchCity, assets) VALUES +("Dhole Patil", "Kharadi", 50000), +("Nagarwala", "Akurdi", 20000), +("Peachtree", "Wakad", 35000), +("Bishops", "Nigdi", 10000), +("Amanora", "Hadapsar", 60000); + +INSERT INTO Customer (customerName, customerStreet, customerCity) VALUES +("Kalas", "Airport Road", "Pune"), +("Mehul", "Shahdha", "Nandurbar"), +("Tanmay", "Porwal Road", "Pune"), +("Kshitij", "Hadapasar", "Pune"), +("Aditya", "Mira RD", "Mumbai"), +("Himanshu", "Smart City", "Nandurbar"); + +INSERT INTO Account (accountNum, branchName, balance) VALUES +(2501, "Dhole Patil", 5000), +(2511, "Nagarwala", 1500), +(2521, "Peachtree", 2000), +(2512, "Bishops", 5000), +(2531, "Amanora", 1000); + +INSERT INTO Loan (loanNum, branchName, amount) VALUES +(155, "Dhole Patil", 500), +(156, "Nagarwala", 250), +(157, "Peachtree", 600), +(158, "Bishops", 900), +(159, "Amanora", 2500); + +INSERT INTO Borrower VALUES +("Kalas", 156), +("Mehul", 158), +("Tanmay", 155), +("Kshitij", 157), +("Aditya", 159), +("Himanshu", 158); + +INSERT INTO Depositor VALUES +("Kalas", 2511), +("Mehul", 2512), +("Tanmay", 2501), +("Kshitij", 2521), +("Aditya", 2531), +("Himanshu", 2512); + +``` + +--- + +## Running queries + +==PENDING== diff --git a/Handouts/Assignment-A3.pdf b/Practical/Assignment-A3/Handout-A3.pdf similarity index 100% rename from Handouts/Assignment-A3.pdf rename to Practical/Assignment-A3/Handout-A3.pdf diff --git a/README.md b/README.md index ba67b9d..e8017c6 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,11 @@ A one-stop Git repository for third year SPPU Computer Engineering students foll 1. [Unit 1 - Introduction to Database Management Systems and ER Model](https://git.kska.io/sppu-te-comp-content/DatabaseManagementSystems/src/branch/main/Notes/Unit%201) -### Handouts +### Practical -1. [Assignment-A2](https://git.kska.io/sppu-te-comp-content/DatabaseManagementSystems/src/branch/main/Handouts/Assignment-A2.pdf) -2. [Assignment-A3](https://git.kska.io/sppu-te-comp-content/DatabaseManagementSystems/src/branch/main/Handouts/Assignment-A3.pdf) +> Each folder contains **handout**, **write-up** and **database**. + +1. [Assignment-A2](https://git.kska.io/sppu-te-comp-content/DatabaseManagementSystems/src/branch/main/Practical/Assignment-A2) +2. [Assignment-A3](https://git.kska.io/sppu-te-comp-content/DatabaseManagementSystems/src/branch/main/Practical/Assignment-A3) ---