0% found this document useful (0 votes)
20 views4 pages

Summ Revision XII IP

Uploaded by

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

Summ Revision XII IP

Uploaded by

as9557504
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Summary notes: DATABASE &SQL:

1. Database: A database is an organized collection of interrelated data.


Software used to manage databases is called Data Base Management System
(DBMS).
2. Relational Database: A database in which the data is stored in the form of relations
(also called tables) is called a Relational Database. In other words a Relational Database is a
collection of one or more tables.
3. RDBMS: A DBMS used to manage Relational Databases is called an RDBMS (Relational
Data Base Management System). Some popular RDBMS software available are: Oracle,
MySQL, Sybase, Ingress.ISION TOUR
4. Benefits of using a DBMS are:
a. Data Redundancy (duplication of data) can be controlled.
b. Data Inconsistency(mitch matching copies of same data) is minimized.
c. Data can be shared easily.
d. Security restrictions can be applied.
5. MySQL: It is an Open Source RDBMS Software. It is available free of cost.
6. Relation/Table: A table or relation is collection of records. One table contains only type
of information.
7. Key: A column or a combination of columns which can be used to identify one or more
rows (tuples) in a table is called a key of the table.
8. Primary Key: The group of one or more columns used to uniquely identify each row of a
relation is called its Primary Key. It maintains data integrity.
Primary key requires NOT NULL(data entry mandatory) and UNIQUE(no duplicates) data.
9. Candidate Key: A column or a group of columns which can be used as the primary
key of a relation is called a candidate key .
10. Alternate Key: A candidate key of a table which is not made its primary key is called its
Alternate Key.
11.Foreign key: It is used to relate two tables .A common column in two tables is normally
taken as Foreign key.
Referential Integrity is maintained by foreign key. It restricts any addition or deletion of data
in one table with reference to data present in another table.
12.Domain: A domain is the original sets of atomic values used to model data.
13.Tuple/Record : A row or record in a table.it is one complete piece of logical information.
14.Attribute or field: A named column in a table.it can have only one type of data,
15.Cardinality: Number of records or tuples in a table.
16.Degree : Number of columns or fields in a table.
17: ALIAS name: alternate name for any column or table
Select RN as “ROLL NO” from student; // here ROLL NO is alias name for RN column
Select P.RN from student as P; // here P is alias name for table student
Operation in relational algebra:
1. Selection 2. Projection 3. Union 4. Cartesian Product
Selection in relational algebra returns those tuples(records) in a relation that fulfill a
condition(Produce table containing subset of rows).
Projection in relational algebra returns those columns in a relation that given in the
attribute list (Produce table containing subset of columns).
UNION:
The union operator is used to combine two or more tables.
Each table within the UNION should have the same number of columns, similar data
types and also the columns must be in the same order. In the union operation,
duplicate records will be automatically removed from the resultant table.
Select * from a union select * from b;
Cartesian product is a binary operation and is denoted by (x) Cartesian product returns a
number of rows equal to number of records in the first table multiplied by number of records
in the second table. At the same time, number of columns equal to number of columns in
the first table added by number of columns in the second table.
Select * from a,b;
1
SQL COMMANDS:
1. SQL (Structured Query Language): It is the language used to manipulate and manage
databases and tables using an RDBMS.
2. DDL (Data Definition Language): This is a category of SQL commands. All the
commands which are used to create, destroy, or restructure databases and tables come
under this category.
Examples of DDL commands are -
CREATE TABLE: Used to create structure of the table.
ALTER TABLE: used to modify structure of a table i.e to add or remove column,
constraints in/from a table
DROP TABLE: To remove table structure along with data.
DROP DATABASE: to remove database.
CREATE VIEW :to create a virtual table that takes data from existing table.
3. DML (Data Manipulation Language): This is a category of SQL commands. All the
commands which are used to manipulate data within tables come under this category. Used
for record maintenance.
Examples of DML commands are –
INSERT INTO: To add record or row values.
SELECT: To display row or column information.
UPDATE :it is used to modify data or record in a table.
DELETE : it is used to delete records in a table
4.CONSTRAINTS: The set of rules or conditions that are used to store valid data in a table.
Example: Primary key,UNIQUE,NOT NULL,Foreign KEY

ALTER TABLE command is used to modify structure of database.


 It is used to add/remove constraints or columns in an existing table.
o ALTER TABLE EMP ADD PHNO BIGINT not null;//adding a column phno with
NOT NULL CONSTARINT
o ALTER TABLE EMP ADD PRIMARY KEY(EMPID);//adding primary key constraint
o ALTER TABLE DEPT ADD FOREIGN KEY(EMPID) REFERENCES
EMP(EMPID);//adding foreign key
o ALTER table emp drop primary key;//to remove primary key
o ALTER table emp drop phno;//to remove a column PHNO
RENAME TABLE : To Change Table Name.
>rename table emp to employee;
DML DDL
1. Data manipulation language is a set 1. Data Definition Language is a set of
of commands for record commands to create or modify
management like add,delte,modify structure of database
,retrieve records. 2. DDL commands are CREATE
2. DML commands are SELECT,INSERT DATABASE,ALTER table,CREATE
,DELETE,UPDATE TABLE,DROP DATABASE,DROP table

CREATE TABLE CREATE VIEW


1. it is DDL command used to create 1. It is used to create a virtual table
table structure. 2. It derives its values from an existing
2. It stores records table
3. Create table emp(code int,ename 3. Create view PP as select * from
char(20)); emp;

JOIN UNION
1. Combining records from two tables 1. Combining records from two tables
having different structure. having similar structure
2. Order and number of columns can 2. Number of columns, column data
be different. types and order of columns must
match
2
3. SELECT * FROM A,B; 3. SELECT * FROM A UNION SELECT *
FROM B;

3
VARCHAR CHAR
1. Used for Variable length 1. Used for Fixed length string
string. 2. Size is not mandatory i.e default size
2. Size is mandatory. is 1.
3. Eg. Sname Varchar(10) will 3. Eg. Sname char(10) will occupy 10
occupy <=10 charcaters. always whether user enters less
characters.
LIKE OPERATOR is used to search a value similar to specific pattern in a column using
wildcard operator.
There are two wildcard operators – percentage sign (%) and underscore ( _ ).
The (%) percentage sign represents zero, one, or multiple characters, while the underscore
(_ ) represents any single character.
Display names, whose name's second letter is 'o'.
SELECT name FROM student WHERE name LIKE "_ o%";
IN: The IN operator is used to check a value in given set of options or list.
It allows us to specify multiple values in a WHERE clause
SELECT * FROM STUDENT WHERE SECTION IN(‘A’,’C’);
Not IN: The not IN operator is used to check a value not present in a given set of options
or list.
It allows us to specify multiple values in a WHERE clause
SELECT * FROM STUDENT WHERE SECTION IN(‘A’,’C’);
IS : IS operator its used to check presence null values in a column
Select * from emp where salary IS NULL;
IS not : IS not operator its used to check absence of null values or not null values in a
column
Select * from emp where salary IS not NULL;
BETWEEN: The BETWEEN operator is used to test a column value in a given range of
values. Both end values are inclusive.(like from 2500 to 3500)
SELECT * FROM student WHERE fees BETWEEN 2500 AND 3500;
Not BETWEEN: The not BETWEEN operator is used to test a column value not present in a
given range of values.
SELECT * FROM student WHERE fees NOT BETWEEN 2500 AND 3500;
DESC or DESCRIBE: to view structure(fields,constraints) of table
USE databasename: used to open or make a database active

You might also like