0% found this document useful (0 votes)
61 views12 pages

Ism File

The document outlines a series of practical exercises involving SQL database operations, including creating tables, inserting data, altering tables, and defining relationships between entities. It covers practical tasks such as creating an Employee table, a Student table, and handling foreign key constraints in Customer and Order tables. Each practical emphasizes connecting to the database and performing various SQL commands to manipulate and retrieve data.

Uploaded by

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

Ism File

The document outlines a series of practical exercises involving SQL database operations, including creating tables, inserting data, altering tables, and defining relationships between entities. It covers practical tasks such as creating an Employee table, a Student table, and handling foreign key constraints in Customer and Order tables. Each practical emphasizes connecting to the database and performing various SQL commands to manipulate and retrieve data.

Uploaded by

gauraviitm123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

PRACTICAL 1

Steps:

1. Connect to the Database:

- Ensure the interface is connected to the database as “BCA1@orcl”.

2. Create a New Table:

- Write an SQL statement to create a table named `Employee` with


columns `EID`, `Name`, `Department`, `Salary`, and `Address`.

3. Insert New Rows:

- Use an SQL `INSERT` statement to add 10 rows with sample values such
as:
- `EID`: 101

- `Name`: "John Doe"

- `Department`: "Sales"

- `Salary`: 50000

- `Address`: "New York, USA"

4. Delete a Column:

- Use an `ALTER TABLE` statement to remove the `Address` column from


the `Employee` table.

5. Add the Column Again:

- Use an `ALTER TABLE` statement to add the `Address` column back to


the `Employee` table.

6. Rename the Table:

- Use an SQL `RENAME` statement to rename the table from `Employee` to


`Employees`.
PRACTICAL 2

Steps:

1. Connect to the Database:

- Ensure the database is connected as “BCA1@orcl”.

2. Create the Student Table:

- Write an SQL statement to create a `Student` table with columns:

- `RollNo`: Primary key

- `Name`: Not Null constraint

- `Age`: Check constraint to ensure positive values

- `Email`: Unique constraint

- `Course`: Course name

3. Insert Rows into the Table:

- Insert 5 rows with values like:


- `RollNo`: 2021

- `Name`: "Akhilesh"

- `Age`: 20

- `Email`: "[email protected]"

- `Course`: "BBA"

4. Apply Primary Key on Roll No.

- Set `RollNo` as the primary key in the table.

5. Apply Not Null Constraint on Name:

- Apply a Not Null constraint on the `Name` column.

6. Apply Check Constraint:

- Add a Check constraint on `Age` to ensure it is positive.

7. Apply Unique Constraint on Email :

- Set the `Email` column to have unique values.


PRACTICAL 3

Steps:

1. Connect to the Database:

- Confirm that you are connected to “BCA1@orcl”.

2. Create a Table:

- Write an SQL statement to create a table with columns `RollNo`, `Name`,


`Age`, `Address`, and `AadharNo`.

3. Insert Records into the Table:

- Insert 5 records with values such as:


- `RollNo`: 2024

- `Name`: "Akhilesh"

- `Address`: "Lucknow"

- `Age`: 20

- `AadharNo`: 856177114196

4. Display Specific Columns:

- Use an SQL `SELECT` statement to retrieve `RollNo`, `Name`, `Age`, and


`AadharNo` from the `Student` table.

5. Filter by Name Starting with “P”:

- Write a query to display records of students whose `Name` begins with


the letter "P".

6. Delete a Record by Roll No.:

- Use a `DELETE` statement to remove the record where `RollNo` is 113.

7. Update Address for Specific Roll No.:

- Write an `UPDATE` statement to change the `Address` for the student


with `RollNo` 115.
PRACTICAL 4

Steps:

1. Connect to the Database:

- Ensure that you are connected to the database.

2. Create a Table for Aggregation:

- Define a table named `SalesData` with columns `SaleID`, `Amount`, and


`Date`.

3. Insert Rows:

- Insert 5 rows with values like:

- `SaleID`: 1001

- `Amount`: 1500

- `Date`: "2024-11-01"

4. Use Aggregate Functions: - Write SQL queries to apply functions:


PRACTICAL 5
Steps:

1. Define the Employee Entity:

- Include attributes: `EID` (primary key), `Name`, `DepartmentID`,


`Salary`, and `Address`.

2. Define the Department Entity:

- Include attributes: `DepartmentID` (primary key) and `DeptName`.

3. Define the Relationship:

- Specify a one-to-many relationship where each `Department` has


multiple `Employees`.

4. Draw the Diagram:

- Illustrate `Employee` and `Department` entities and connect them with a


relationship.
PRACTICAL 6

Steps:

1. Connect to the Database:

- Confirm the connection to “BCA1@orcl”.


2. Create Customer and Order Tables:

- Define a `Customer` table with `CustomerID`, `Name`, and `Contact`.

- Define an `Order` table with `OrderID`, `OrderDate`, `TotalAmount`, and


`CustomerID` (Foreign Key).

3. Add Foreign Key Constraint:

- Set `CustomerID` in `Order` as a foreign key referencing `CustomerID` in


`Customer`.

4. Insert Rows into Both Tables:

- Insert 5 records in each table, linking `Order` records to `Customer`


records.

5. Delete Records with Foreign Key:

- Delete 2 rows from `Order` to demonstrate the foreign key behavior.


PRACTICAL 7

Steps:

1. Define the Customer Entity:

- Attributes: `CustomerID` (primary key), `Name`, `Email`, `Phone`, and


`Address`.

2. Define the Order Entity:

- Attributes: `OrderID` (primary key), `OrderDate`, `TotalAmount`, and


`CustomerID` (foreign key).
3. Define the Product Entity:

- Attributes: `ProductID` (primary key), `ProductName`, and `Price`.

4. Define Relationships:

- Specify a one-to-many relationship between `Customer` and `Order`.

- Define a many-to-many relationship between `Order` and `Product`.

5. Draw the Diagram:

- Illustrate `Customer`, `Order`, and `Product` entities and connect them


accordingly.

You might also like