QSpiders - SQL (Data Base)

12
QL (Data Base

Transcript of QSpiders - SQL (Data Base)

Page 1: QSpiders - SQL (Data Base)

SQL (Data Base)

Page 2: QSpiders - SQL (Data Base)

Data is a useful information. Which helps to make a decision.Set of information of any entity is known as data.Example:

Employee information.(Name,job,sal etc…)Product informationSales information

• What is Data?

Page 3: QSpiders - SQL (Data Base)

•What is Database ?Place where you store dataA database is a systematic collection of data. Databases support storage and  manipulation of data.Databases make data management easy.Ex:

An online telephone directory.Electricity service providerFacebook.

Page 4: QSpiders - SQL (Data Base)

• What is a Database Management System (DBMS)?

Database Management System (DBMS) is a collection of programs which enables its users to access database, manipulate data, reporting / representation of  data .

Data base combined with management system services is known as DBMS.

Page 5: QSpiders - SQL (Data Base)

Oracle 2, Oracle 3, Oracle 4, Oracle 5, Oracle 6,

Oracle 7, Oracle 8i, Oracle 9i, Oracle 10g,Oracle 11g

and the latest to hit the market is Oracle 12c. here ‘i’ stands for Internet, ‘g’ stands for Grid / Grid computing and C for Cloud Computing .

• Here the services are.Entering new dataUpdating old data with new dataDeleting unwanted dataAuthenticating the usersProviding security

• The s/w which is widely used today is Oracle. • The different versions of Oracle starting from

the earliest to the latest are –

Page 6: QSpiders - SQL (Data Base)

•What is Relational Database? It is the collection of relations or two dimensional tables Dr E.F Codd proposed the relational model for database system in 1969 Relational Model Consists of following

Collections of Objects or Relations Set of Operators to act on the relations Data integrity for accuracy and consistency.

( Data integrity is the one which contains correct data in the database) To restrict storing wrong data in database we use data integrity. To Preserve data integrity we have two types1.DataType:2.Constraints:Data Type is a type of data which you store in each column.

Page 7: QSpiders - SQL (Data Base)

A constraint is a condition which restricts the invalid data in the table. A constraint can be provided for a column of a table.

•ConstraintsA constraint is a condition which restricts the invalid data in the table.

A constraint can be provided for a column of a table. •Types of Constraints

NOT NULL UNIQUE Primary Key

Foreign Key Check

Page 8: QSpiders - SQL (Data Base)

• Null NULL is nothing, it is neither

zero nor blank space It will not occupy any space in

the memory Two NULLS are never same in

Oracle NULL represents unknown value Any arithmetic operation we

perform on NULL will result in NULL itself. For ex, 100000 + NULL = NULL ;

100000 * NULL = NULL

Page 9: QSpiders - SQL (Data Base)

•Not Null NOT NULL will ensure at

least some value should be present in a column

• UniqueIt will not allow any duplicates in a columnUNIQUE column can take multiple NULL (s)

Page 10: QSpiders - SQL (Data Base)

• Primary Key It is the combination of NOT NULL and UNIQUE

Only one PK is allowed in a tablePK identifies a record uniquely in a table

Creation of PK is not mandatory, but it is highly recommended to create

Candidate Key: Eligible to become PK

Alternate Key: Eligible to become primary key but not chosen as PK

CK=PK+AKAK=CK-PK

Page 11: QSpiders - SQL (Data Base)

• Foreign KeyFK creates relationship between any two tables

FK is also called as referential integrity constraints

FK is created on the child tableFK can take both NULL and duplicate values

To create FK, the master table should have PK defined on the common column of the master table

We can have more than 1 FK in a given table

Page 12: QSpiders - SQL (Data Base)

•CheckIt is used to provide additional validations as per the customer requirements.