0% found this document useful (0 votes)
2 views11 pages

CSC SQL 1

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)
2 views11 pages

CSC SQL 1

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

DATA BASE CONCEPTS

• A file can be understood as a container to store data in


a computer. Files can be stored on the storage device of
a computer system. Contents of a file can be texts,
computer program code, comma separated values
(CSV), etc. Likewise, pictures, audios/videos, web pages
are also files.
• Files stored on a computer can be accessed directly and
searched for desired data. But to access data of a file
through software, for example, to display monthly
attendance report on school website, one has to write
computer programs to access data from files.
DATA BASE CONCEPTS
• File system becomes difficult to handle when number
of files increases and volume of data also grows.
1. Difficulty in Access
– Files themselves do not provide any mechanism to retrieve
data. Data maintained in a file system are accessed through
application programs.
2. Data Redundancy
– Redundancy means same data are duplicated in different
places (files). Redundancy leads to excess storage use and
may cause data inconsistency also.
3. Data Inconsistency
– Data inconsistency occurs when same data maintained in
different places do not match.
DATA BASE CONCEPTS
4. Data Isolation
– Files have no link or mapping between them. Files being
created in isolation may be of different formats. This is
because data mapping is not supported in file system.
5. Data Dependence
– Data are stored in a specific format or structure in a file. If the
structure or format itself is changed, all the existing
application programs accessing that file also need to be
change.
6. Controlled Data Sharing
– Ideally, not every user should be able to access all the data.
DATA BASE CONCEPTS
• Limitations faced in file system can be overcome by
storing the data in a database where data are logically
related. We can organise related data in a database so
that it can be managed in an efficient and easy way.
• A database management system (DBMS) or database
system in short, is a software that can be used to create
and manage databases. DBMS lets users to create a
database, store, manage, update/modify and retrieve
data from that database by users or application
programs. Some examples of open source and
commercial DBMS include MySQL, Oracle, PostgreSQL,
SQL Server, Microsoft Access, MongoDB.
DATA BASE CONCEPTS
• A database system has a set of programs through which
users or other programs can access, modify and retrieve
the stored data.
• The DBMS serves as an interface between the database
and end users or application programs. Retrieving data
from a database through special type of commands is
called querying the database. In addition, users can
modify the structure of the database itself through a
DBMS.
DATA BASE CONCEPTS
Key Concepts in DBMS:
• Database Schema - It is the skeleton of the database that
represents the structure (table names and their fields/columns),
the type of data each column can hold, constraints on the data
to be stored (if any), and the relationships among the tables.
• Data Constraint - Sometimes we put certain restrictions or
limitations on the type of data that can be inserted in one or
more columns of a table. This is done by specifying one or more
constraints on that column(s) while creating the tables. (NOT
NULL and UNIQUE constraints).
– Domain constraints in DBMS. A domain is a unique set of
values permitted for an attribute in a table. For example,
a domain of month-of-year can accept January, February….
December as possible values, a domain of integers can accept
whole numbers that are negative, positive and zero.
RDBMS
Relational Data Base Management System
• In relational model, tables are called relations that
store data for different columns. Each table can have
multiple columns where each column name should be
unique. Each row in the table represents a related set
of values.
• There are many RDBMS such as MySQL, Microsoft SQL
Server, PostgreSQL, Oracle, etc. that allow us to create
a database consisting of relations and to link one or
more relations for efficient querying to store, retrieve
and manipulate data on that database.
RDBMS
• One has to write application programs to access data in
case of a file system. However, for database
management systems there are special kind of
programming languages called query language that can
be used to access data from the database.
• The Structured Query Language (SQL) is the most
popular query language used by major relational
database management systems such as MySQL,
ORACLE, SQL Server, etc.
SQL
• A database consists of one or more relations and each
relation (table) is made up of attributes (column). Each
attribute has a data type. We can also specify constraints
for each attribute of a relation. Data type indicates the
type of data value that an attribute can have.
Commonly used data types in MySQL
• CHAR(n) Specifies character type data of length n
where n could be any value from 0 to 255. CHAR is of
fixed length.
• VARCHAR(n) Specifies variable-length character type
data of length ‘n’ where n could be any value from 0 to
65535.
SQL
• INT specifies an integer value. Each INT value occupies 4
bytes of storage. The range of values allowed in integer
type are -2147483648 to 2147483647. For values larger
than that, we have to use BIGINT, which occupies 8
bytes.
• FLOAT Holds numbers with decimal points. Each FLOAT
value occupies 4 bytes.
• DATE type is used for dates in 'YYYY-MM-DD' format.
YYYY is the 4 digit year, MM is the 2 digit month and DD
is the 2 digit date. The supported range is '1000-01-01' to
'9999-12-31'.
SQL
• Constraints are certain types of restrictions on the
data values that an attribute can have. They are used
to ensure the accuracy and reliability of data.

You might also like