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/ 48
1
Department of Computing, FCIT, Indus University
INDUS UNIVERSITY
Department of Computing, FCIT, Indus University 2
Course Title: Database Systems (3 CH) Pre-requisites: Not Required
Department of Computing, FCIT, Indus University 3
Course Plan
5. An Introduction to Database Systems 8th Edition CJ Date
Department of Computing, FCIT, Indus University 4
Course Plan
Department of Computing, FCIT, Indus University 5
Database concepts, database vs files base WEEK 2
Department of Computing, FCIT, Indus University
Table of Content 1) Database concepts 2) External, conceptual and Internal Level 3) database vs file base
Department of Computing, FCIT, Indus University
Database Concepts: A database intends to have a collection of data stored together to serve multiple applications as possible. Hence a database is often conceived of as a repository of information needed for running certain functions in a corporation or organization. Such a database would permit not only the retrieval of data but also the continuous modification of data needed for control of operations. It may be possible to search the database to obtain answers to queries or information for planning purposes.
Department of Computing, FCIT, Indus University
Purpose of Database: A Database should be a repository of data needed for an organization's data processing. That data should be accurate, private, and protected from damage. It should be accurate so that diverse applications with different data requirements can employ the data. Different application programmers and various end-users have different views upon data, which must be derived from a common overall data structure. Their methods of searching and accessing of data will be different.
Department of Computing, FCIT, Indus University
Data Independence The data Independence is implemented through three general levels. These levels are: 1) Physical level 2) Conceptual Level 3) External Level
Department of Computing, FCIT, Indus University
Basic Terminologies Related To Database And SQL Relation: In general, a relation is a table, i.e., data is arranged in rows and columns. A relation has the following properties: For Column in a table, all the items are of the Same kind, whereas items in Different Columns may not be of the same kind. For a Row, each column must have an Atomic value, and also for a row, a column cannot have more than one value. All rows of a relation are distinct.
Department of Computing, FCIT, Indus University
Basic Terminologies Related To Database And SQL Basic Terminologies Related To Database And SQL The column of a relation are assigned Distinct names, and the ordering of these columns is immaterial. Tuple: The rows of tables in a relationship are generally termed as Tuples. Attributes: The columns or fields of a table is termed as Attributes. Degree: The number of Attributes it Contain in a relation, the degree of relation. E.g. A relation having three attributes is said to have a relation of degree 3. Cardinality: The number of tuples or rows in a relation is termed as cardinality.
Department of Computing, FCIT, Indus University
Basic Terminologies Related To Database And SQL Q1. How Many Tuples In this table? Q2. How Many Attributes In this table? Q3. Find the Cardinality of this Relation? Q4. What is the Degree of this Relation?
Department of Computing, FCIT, Indus University
Basic Terminologies Related To Database And SQL Q1. How Many Tuples In this table? Ans. Five Tuples Q2. How Many Attributes In this table? Ans. Three Attributes Q3. Find the Cardinality of this Relation? Ans. Cardinality 5 Q4. What is the Degree of this Relation? Ans. Degree 3
Department of Computing, FCIT, Indus University
How Is Organized Data Stored Efficiently? The most efficient way to store data is with the help of a relational database. A relational database consists of 3 high- level components: oTables oRelationships oKeys
Department of Computing, FCIT, Indus University
Table
Department of Computing, FCIT, Indus University
Columns
Department of Computing, FCIT, Indus University
Columns Columns are used to differentiate the information we have on a single observable entity. In a Table that contains information about people, the columns would be used to hold different information.
Department of Computing, FCIT, Indus University
Rows
Department of Computing, FCIT, Indus University
Rows Rows of a table represent the number of observable entities we are looking at. To put it simply, if the people table has 3 rows, it means it has the data of 3 different people. Each row represents an individual person and the columns will display their respective information.
Department of Computing, FCIT, Indus University
Keys Keys allow Unique identification for all rows in the table. Without keys there would be no way to differentiate between entries that have identical information in their columns. Two people in a table can have the same names and birthdays and without a unique key, it will be hard to differentiate between them and can lead to unnecessary confusion. Suppose you’re an HR person who has to send a termination letter to a guy named John.
Department of Computing, FCIT, Indus University
Some Keys of Database oSuper Key oCandidate Key oPrimary Key oAlternate Key oForeign Key oComposite Key
Department of Computing, FCIT, Indus University
Super Key oEvery key in a table which can Uniquely identify a record. oSuper key is a Superset of a candidate key. oA Table can have many Super Keys.
Department of Computing, FCIT, Indus University
Super Key
Department of Computing, FCIT, Indus University
Candidate key oThe Minimal set of Attributes which can uniquely identify a Tuple is known as Candidate key. oIt may be Single Attribute or set of attributes.
Department of Computing, FCIT, Indus University
Candidate key
Department of Computing, FCIT, Indus University
Candidate key
Department of Computing, FCIT, Indus University
Primary Key oPK is an attribute or set of attributes which helps you to uniquely identify a row(tuple) in a relation(table). oIt is chosen from Candidate key according to our need. oIt can Not be Null. oTwo rows haven’t the same Primary key Department of Computing, FCIT, Indus University Primary Key
Department of Computing, FCIT, Indus University
Alternate Key oThose Attributes are Remaining in Primary Key that is called Alternate Keys.
Department of Computing, FCIT, Indus University
Foreign Key Foreign Keys are used to link tables together within a database. These links are called relationships. The purpose of Foreign Key is to Ensure or Maintain Referential Integrity of the data because of all Referencing or Linked Table must be updated.
Department of Computing, FCIT, Indus University
Foreign Key Student Table Primary Key
Library Table
Foreign Key
Department of Computing, FCIT, Indus University
Composite Key A primary key having two or more attributes is called composite key. It is a combination of two or more columns.
Department of Computing, FCIT, Indus University
Composite Key
Get Marks of Student ID (201)
Department of Computing, FCIT, Indus University Composite Key
Composite Key = StudentId + Course
Department of Computing, FCIT, Indus University Composite Key
Get Marks of Student
ID (201) + Course (Quality Assurance)
Department of Computing, FCIT, Indus University
Composite Key
Get Marks of Student
ID (201) + Course (Quality Assurance)
=75
Department of Computing, FCIT, Indus University
Database VS File System
Department of Computing, FCIT, Indus University
File System : The file system is basically a way of arranging the files in a storage medium like a hard disk. The file system organizes the files and helps in the retrieval of files when they are required. File systems consist of different files which are grouped into directories. The directories further contain other folders and files. The file system performs basic operations like management, file naming, giving access rules, etc. Department of Computing, FCIT, Indus University File System : In File System the Data is in the System only I can Access the data and as a user, only I can save the data and only I can use the data. So its Easy to Maintain My Data. As we See even today, what comes in our Computer / Laptop it’s (File System) it’s Built in the Operating System. Department of Computing, FCIT, Indus University So Why do we use DBMS Because we are now using the client-server Architecture. Everyone Can Access the data all over the world, just because the data is in a Centralized Location
Department of Computing, FCIT, Indus University
Database Management System: Database Management System is basically software that manages the collection of related data. It is used for storing data and retrieving the data effectively when it is needed. It also provides proper security measures for protecting the data from unauthorized access. In Database Management System the data can be fetched by SQL queries.
Department of Computing, FCIT, Indus University
File System VS DBMS o We have a database that occupies 50 GB of memory, Search out only 2 KB of Data so, in the File system it gives the complete file of 50 GB while in DBMS it fetches only 1 KB data, in DBMS it Holds the Data on Server.
o To Access data in File System there is requirement of
Attributes Location / Directory while DBMS it doesn’t need. Department of Computing, FCIT, Indus University File System VS DBMS o Redundant data can be o In DBMS there is no redundant present in a file system. data. o It doesn’t provide backup o It provides backup and recovery and recovery of data if it is of data even if it is lost. lost. o It has more complexity in o It is less complex as handling as compared to the file compared to DBMS. system. o Only one user can access o Multiple users can access data data at a time. at a time. Its called Concurrency
Department of Computing, FCIT, Indus University
Database Systems
Refer to Text Book: An Introduction to Database Systems 8th Edition
CJ Date Chapter 2 THANK YOU ☺ Department of Computing, FCIT, Indus University