You are on page 1of 10

Data type supported by DBMS:1.

Numeric: y Numeric data are the data on which you can perform arithmetic procedure. y EX: STD_HRS, SALARY. We can perform arithmetic manipulations like add, subtract, multiply and divide. 2. Character: y Character data contains any character or symbol. y Ex: STD_LASTNAME, STD_FNAME 3. Date: y Date attribute contains calendar date. y Ex: STD_DOB 4. Logical: y Logical data can have a true or false condition. Oracle: 1. y y y 2. y y 3. y y y Number SAL Number(5) -No. of digit to be LEAVE RollNo Number(3) Price Number(4,2) Char char(20) -fixed length varchar(20) -variable length Date DD-MON-YY BLOB: Binary Large Object CLOB: Character large object

y A columns range of permissible values is called as domain. each table must have a primary key which uniquely identifies each row. Keys: 1. Candidate key 2. Super key 3. Primary key Candidate key: y A candidate key is described as a super key that is a minimal super key. A primary key is the candidate key chosen to be uniquely identified. So, primary key is a super key as well as candidate key. Super key: y A super key is any key that uniquely identifies each row. Composite Key: y A key Composed of more than one attribute is known as composite key. Foreign Key: y An attribute or a combination of attributes in one table whose values must match the primary key in another table or be null. Secondary key: y Secondary key is defined as an attribute or combination of attributes used for data retrieval. y CREATE TABLE EMP (Empno Number(3), Sal Number(5), Name varchar2(20), DOB date);

y CREATE TABLE STUDENT (Rollno Number(3), Name varchar2(20), DOB Date, Address varchar(20), Telno Number(10)); Integrity Rules: 1. Entity Integrity: y Requirement: All Primary key entries are unique and no part of primary key can be null. y Purpose: Each row will have a unique identify and foreign key values can reference primary key value. y Example: No invoice can have a duplicate number or can be NULL. 2. Referential Integrity: y Requirement: A Foreign key may have either a null entry or an entry that matches the primary key value in a table to which it is related. y Purpose: It is impossible to make an invalid entry. y Example: A customer is assign sales representative number which cannot be invalid. Relational Set Operator: 1. Union y Union combines all rows from two tables excluding duplicate rows. y The tables must have columns and domains identical when two or more table share the same number of columns, when the columns have same name and same domain they are called as union compatible. A B

1 2

A UNION B 1 2 3 2. Intersect y Intersect gives the rows that appears in both the tables. The tables must be UNION compatible to get valid result. E_NAME F_NAME G J J W W D Yields F_NAME J W

F_NAME G

E W F_NAME G J E W

3. Difference F_NAME J A D

4. Product y Product gives all possible pairs of rows from two tables called as cartesion product. If one table has six rows and other table has three rows product gives 18 rows. y Difference gives all rows in one table. It subtracts one table from other. It should be UNION compatible to get valid result. 5. Select y Select (Restrict) gives value for all rows found in a table. It lists all the row values or the rows that match specific condition SELECT gives a horizontal subset of a Table. 6. Project y Project gives all values for selected attribute. Project gives vertical subset of a table. 7. Join y It allows the information to be continued from two or more tables. The types of join are : I. Natural Join y It is a three stage process of product, select, project.

EMPNO 1 2

EMP ENAME ABC DAC

DEPTNO 10 20

DEPT DEPTNO DNAME 10 SALES 20 HR EMP PRODUCT ENAME DEPTNO ABC 10 ABC 10 DAC 20 DAC 20

EMPNO 1 1 2 2

DNAME SALES HR SALES HR

SELECT EMP EMP_NO Ename Deptno 1 ABC 10 2 DAC 20 EMP.DEPTNO = DEPT.DEPTNO EXAMPLE: STUDENT ROLLNO DEPTNO SNAME 1 5 SHAH 2 6 PATEL DEPT Bca Bba

Deptno 10 20

Dname Sales HR

5 6

4 5

Product ROLLNO 1 2 1 2 SELECT 1 2

DEPTNO 5 6 5 6

SNAME SHAH PATEL SHAH PATEL

DEPTNO 5 6 6 5

DNAME BCA BBA BBA BCA

LOC 4 5 5 4

5 6

SHAH PATEL

5 6

BCA BBA

4 5

STUDENT.DEPTNO=DEPT.DEPTNO y A natural join links the table with common values in their common attribute. PRODUCT: It performs a Cartesian product on both the tables. SELECT: A SELECT is perform where the common attributes have common value, the common columns are called join column. PROJECT: It is perform to give the vertical subset of each attribute by removing duplicate column. II. Equi Join y It joins the table based on equality condition. It does not remove duplicate columns and the condition for join should be given explicitly. We use equality comparison operator (=) for the join operation. III. Theta Join y If any other comparison operator is used, it is called as theta join.

IV. Left Outer Join y Left outer join gives all the rows in the left table including those that do not match with the value in the right table. V. Right Outer Join y It gives all the rows in the right table including those that do not have matching value in the left table. VI. Divide Code Loc A 5 C 7 D 8 E 6 y DIVIDE requires one single column and one two column table. Data Dictionary and System Catalog: y Data Dictionary provides detailed accounting of all tables found in the database. It gives the attribute name and properties of each table in the system. y System catalog contains metadata it is a detailed system data dictionary that describes all objects in the database including data about table names, table creator, no. of columns in each table, data type, and authorized users. y Homonym: Similar sounding words with different meaning. Ex: fair (good) (festival) y Synonym: It is opposite of homonym it uses different names to describe the same attribute.

Relationship within relational database: 1. 1:1 One to One

One store one Manager

1 Dept 1 Dept Head

2. 1:M One to Many

CRS_NO CRS_NAME 1 BCA 2 BBA

CRS_NO CLASS_ID 1 602 2 502

STORE

DEPT P.K.DEPT_NO DNAME

EMP EMP_NO-P.K DEPT_NO-F.K

DEP PK DEPTNO DNAME

STU STUID-PK DEPTNO-FK

3. M:M Many to Many

SUPPNO SNAME S100 S1 S101 S2

PRODNO PNAME 1 RADIO

SUPPNO PRODNO PRICE S100 1 1000 S101 2 1500

Index: y It is defined as orderly arrangement used to logically access rows in a table.

SUPP_M

You might also like