Download presentation
Presentation is loading. Please wait.
1
Database Management System
Lessson-01 Date: 09/05/2018 Chapter-06 Database Management System
2
Todays Lesson…………. Concept of Database
3
What is database? Organized collection of meaningful data
Collection of related data about any object. Sl.No Name Roll Class form 1 Samin 59 VI A 2 Wasif 101 VII B 3 Raisa 67 VIII 4 Xima 45 IX 5 Sumaiya 65 X 6 Fahimul 89 XII
4
Basic elements of a database
Record Field Sl.No Name Roll Class form 1 Samin 59 VI A 2 Wasif 101 VII B 3 Raisa 67 VIII 4 Xima 45 IX 5 Sumaiya 65 X 6 Fahimul 89 XII Table
5
Entity, Attribute and values
An object which is distinguishable from other object. Example: Student, Book, Product etc. Attribute: Elements that expressses characteristics of an entity. Example: Name, Roll, Class, Address etc.
6
Attribute Class Roll Name Address Entity Student
7
Summary Define database Define field and record.
Deifne entity and attribute Difference between field and record
8
Sample MCQ Smallest unit of database is…… Ans: field
Number of field in a database is…… Ans: Unlimited Every element of an entity is called….. Ans: Attribute
9
HW What is Database? Draw a database and identify different elements.
Define entity attribute and value of attribute with example. Explain difference between field and record.
10
Todays lesson……… KEY Field
11
What is key field? The unique field of a database which is used to search or retrieve record from database is called key field. Roll, Emp_id, Regno, Social Security Number, IDNo etc may be the key fields
12
Types of Key field Primary Key Composite Primary Key Foreign Key
13
Primary Key The key field which is used to uniquely identify record from a database table is called primary key. Primary key Emp_ID Name Designation Salary 120956 Sajjad Khan Professor 120957 Sadia Islam Associate Prof. 120856 Amzad hossain Assistant Prof 130957 Samsul Arefin Lecturer
14
Composite Primary Key Composite primary key is defined as the key field which is formed by combining two or more fields of a database to uniquely identify record from a database. Composite Primary key Roll Board Name Session 120956 Dhaka Maisha Mehzabin Barishal Tanvir Rahman 120856 Jashore Sadman Sakib Rajshahi Samin Yasar Cumilla Monira Sultana
15
Foreign Key In relational database, primary key of one table is used as general key of another table. Primary key of first table is called foreign key of second table. Primary key/Foreign Key Student Result Roll Name Address 60 Maisha Uttara 61 Tanvir Gazipur 62 Sadman Gulshan 63 Samin Banani Roll Marks GPA 60 900 5.00 61 850 4.50 62 950 63 980
16
DBMS Collection of data and set of rules that are used to access those data is called DBMS. Application-01 Application-02 Application-03 DBMS FILE
17
Different types of Database Management software
MySQL SQLite SQL Server MS Access Oracle dBASE FoxPro
18
Main functions of DBMS To create new database
To insert new record into database Error correction of data To Remove unnecessary record To arrange the records on the basis of any field. To search specific record. To establish link/relation with many tables To prepare customize form To prepare formatted report
19
Uses of DBMS DBMS is used in………. Office management
Bank/Insurance to maintain customer account Chain shop(buy, sell, profit , loss calculation) Educational institution(Exam result, routine, stdinfo etc) Airlines, Railway,Hotel(reservation, schedule maintanance) Hospital, research/survey etc Large organization To store records of employees
20
Emphasize should be given on the Following points before creating database
Objective of the database Nature of database user(General, Online, Application, DBA) Number of table Number of fields in each table Data type Field length Field property etc
21
THANK YOU
22
Lesson-03 Data type
23
In every field of a database table we can store specific type of data as per our requirement.
The type of data is defined while designing table as shown in the following figure. Data types
24
Stdinfo table
25
Brief description of data types
Auto number It is used for series type data. Advantage: Data is entered automatically after the entry of previous record.(No manual entry) Example: Sl.No, empid, roll, regno etc. Text It is used for character (Letter, digit, symbol) based data. Up to 255 characters can be written in this field. Example: Name, F_Name,Designation, Address etc.
26
Brief description of data types
Number It is used for Numeric data entry. Both integer and whole number can be used but no letters is allowed here. Example: Marks, GPA, Mobileno etc. Currency It is used for money related data Example: any kind of fees, Salary, price etc
27
Brief description of data types
Date time It is used for time and date related data. Example: DOB,J_Date, Admission_Date etc. Types General date: 10/30/2018 5:34:23 PM Long Date: Tuesday, June 19, 2007 Medium Date: 19-Jun-07 Short Date: 6/19/2007
28
Brief description of data types
Logical It is used for yes/no, true/false, on/off type data. Size of this field is 1 Example: present-absent, married-unmarried, skilled-unskilled, passed-failed etc. Memo It is used for the field having huge characters as field value. Maximum characters are allowed here. Example: Product description, work experience, job description etc.
29
Brief description of data types
OLE Object Full form of OLE is Object Linking and Embedding. It is used to add different objects with the database. Objects may be doc, xls,pdf,html, ppt,jpg,mp3, mp4 etc. Example: photo, markssheet, report etc. Hyperlink It is used to establish link between webpage and database. Example: webaddress of any organization
30
Brief description of data types
Look up wizard This data type is used for inputting data from prepared list. Example: class, district, form, blood group, country, group etc.
31
Vacation work Prepare 30 MCQ from this chapter
38
END
39
Query What is query? To search necessary data from one or more
table under specific condition is known as query. Query command is used to search, retrieve, display and print information. As for example the expression Roll=224 can be created to search record of a student from student table whose roll is 224.
40
Types of query Query may be of different types. Such as:- Select Query
Parameter query Crosstab Query Maketable Query Action Query
41
Select Query The query which is based on field and record of a data table is known as Select query. Let we want to display all the records of student table, so the respective select query command will be as follows:- SELECT * From Student;
42
Parameter Querie The query that is performed by entering parameter value through dialog box is called parameter query.
43
Crosstab query The query which is performed by imposing condition and represent data as summary report is known as crosstab query. A crosstab query is a matrix, where the column headings come from. the values in a field. Make table query: The query can be used to join several tables or return a subset of columns or rows from the original data in the database. Make table query produces a new table that contains the desired for which the query is made.
44
The above three statements and their syntaxes are stated in the following table.
Action query: Action queries are queries that make changes to many records at once. They are used to delete records, to update records (that is, to change values in them), to create new tables, to delete tables and to launch queries that accept a user-supplied parameter. The above three statements and their syntaxes are stated in the following table. Statement Syntax INSERT INSERT INTO Table_name (fiels1, field2, field3…) VALUES (Val1, val2, val3…); DELETE DELETE FROM Table_name WHERE some_field=some_val; UPDATE UPDATE table_name SET field1=val1, field2=val2
45
QUERY language Query language (QL) refers to any computer programming language that requests and retrieves data from database and information systems by sending queries. There are three types of query languages.Such as:- QUEL (Query Languages) QBE (Query BY Example SQL (Structured Query Language)
46
SQL SQL (Structured Query Language) is a programming language designed for managing data in relational database management systems (RDBMS).
47
There are two types of SQL. Such as:- DDL (Data Definition Language)
DML( Data Manipulation Language) DDL: A data definition language or data description language (DDL) is a syntax similar to a computer programming language for defining data structures, especially database schemas. Following statements are used under DDL. CREATE table DROP table ALTER table
48
1. SQL CREATE TABLE Statement
The CREATE TABLE statement is used to create a new table in a database. Syntax CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype, .... );
49
Following 4 tasks are considered as Data Manipulation.
SQL inDML Following 4 tasks are considered as Data Manipulation. Retrieve Insert Delete Update
50
Retrieve data from database table:
Example 1:Write down SQL command to retrieve all the records from employee table. Soln: SELECT * FROM employee;
51
SELECT Name, Designation, Salary FROM employee; Output:
Example 2: Write down SQL command to retrieve Name, Designation and Salary of the employees from the employee table. SELECT Name, Designation, Salary FROM employee; Output: Example 2: Write down SQL command to retrieve Name, Designation and Salary of the employees from the employee table. SELECT Name, Designation, Salary FROM employee; Output:
52
where address="uttara";
Example 3: Write down SQL command to retrieve records of the employees from the employee table whose address is at Uttara. SELECT *from employee where address="uttara"; Example 4: Write down SQL command to retrieve records of the employees from the employee table who’s Salary is more than Tk and skill is Good. SELECT *FROM employee where (Salary>50000) and (skill="Good");
53
1.SQL INSERT Statement. The INSERT INTO statement is used to insert new records in a table. Syntax: INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...); Example: INSERT INTO student (StdName, Roll,Class, Address,DOB,Contact) VALUES (‘Tajwar',‘XII-Sc-A’.,’H#14, R#12, Sector#6, Uttara‘,10-Jan-2000); 2. SQL UPDATE Statement The UPDATE statement is used to update existing records in a table. Syntax UPDATE table_name SET column1=value1,column2=value2,... WHERE some_column=some_value; Example: UPDATE Student SET Class=“XII-Sc-B” WHERE Roll=101;
54
SQL DELETE Statement The DELETE statement is used to delete rows in a table. Syntax: DELETE FROM table_name WHERE some_column=some_value; Example: DELETE FROM Student WHERE Roll=105;
55
Example: UPDATE Student SET Class=’XII’, Form='A' WHERE Roll=101;
3. SQL DELETE Statement The DELETE statement is used to delete rows in a table. Syntax: DELETE FROM table_name WHERE some_column=some_value;
56
Types of Database Relationships
There are four different types of database relationships, each named according to the number of table rows that may be involved in the relationship. Each of these four relationship types exists between two tables. These are:- One to One relation One to Many relation Many to One relation Many to Many relation.
57
One to one
58
One to Many
59
Many to One
60
Many to Many It occur when each record in the first table corresponds to one or more records in the second table and each record in the second table corresponds to one or more records in the first table. It is very complex to establish many to much relation
61
Other examples of Many to Many relation
A author has contributed to many book, a book is written by many authors In a Sales database, each product belongs to one or more groups, and each group contains multiple products In banking, a customer can have different accounts, and an account can belong to different customers. In insurance, a customer (or household) can have different policies, but a policy can support multiple customers (or households). In many businesses, a parent customer can have subsidiaries.
62
Wish You all the best A+
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.