Assignment 03
Assignment 03
1) What is SQL, and what are some common uses for it in database management?
2) What is a foreign key in SQL, and how is it used to establish relationships
between tables?
DATABASE CREATE:-
1. Create a database ‘classroom’
2. Create a table named ‘science_class’ with the following properties
3 columns(enrollment_no int, name varchar, science_marks int)
UPDATING TABLES:-
1. Update the marks of popeye to 45
2. Delete the row containing details of the student named ‘robb’
3. Rename column ‘name’ to ‘student_name’
SQL (Structured Query Language) is a programming language used for managing and
manipulating relational databases. It is the standard language for relational database
management systems (RDBMS) such as MySQL, PostgreSQL, SQL Server, Oracle, and SQLite.
SQL provides a standardized way to interact with databases, allowing users to perform
various operations like querying, inserting, updating, deleting, and managing database
structures.Here are some common uses of SQL in database management:
1. Querying Data: SQL allows users to retrieve data from databases using the SELECT
statement. Users can specify criteria to filter data, sort results, and perform calculations on
retrieved data.
2. Modifying Data: SQL provides commands such as INSERT, UPDATE, and DELETE to add,
modify, and remove data from database tables.
3. Creating and Modifying Database Structures: SQL allows users to define the structure of
databases and database objects such as tables, indexes, views, and stored procedures using
commands like CREATE, ALTER, and DROP.
4. Data Integrity and Constraints: SQL supports the definition of constraints such as primary
keys, foreign keys, unique constraints, and check constraints to ensure data integrity and
enforce business rules.
5. Data Manipulation and Transformation: SQL provides functions and operators for
manipulating and transforming data, such as arithmetic operations, string functions, date
and time functions, and aggregate functions like SUM, AVG, COUNT, MIN, and MAX.
6. Data Security: SQL allows users to manage database security by defining user permissions
and roles to control access to data and database objects.
7. Data Backup and Recovery
CustomerID INT,
OrderDate DATE,
);
In the above example, the CustomerID column in the Orders table is a foreign key that
references the CustomerID column in the Customers table. This establishes a relationship
between the Orders table and the Customers table, indicating that each order must be
associated with an existing customer.
Use database;
name VARCHAR(255),
science_marks INT
);
ENCLOSED BY '"'
IGNORE 1 LINES;
3.SELECT * FROM science_class WHERE science_marks > 35 AND science_marks < 60;