0% found this document useful (0 votes)
12 views

Database

A database is an organized collection of structured data stored electronically in a computer system. It is usually controlled by a database management system. A file system defines how files are stored and retrieved from a storage device. It allows operating systems to load files from storage. Some limitations of file systems include slow access times, redundant data using more storage space, and difficulties recovering corrupt data. In a relational database, data is organized into tables with rows and columns. Each table represents an entity with attributes defined by columns. Keys like primary and foreign keys link data across tables and ensure data integrity.

Uploaded by

gooda6201
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Database

A database is an organized collection of structured data stored electronically in a computer system. It is usually controlled by a database management system. A file system defines how files are stored and retrieved from a storage device. It allows operating systems to load files from storage. Some limitations of file systems include slow access times, redundant data using more storage space, and difficulties recovering corrupt data. In a relational database, data is organized into tables with rows and columns. Each table represents an entity with attributes defined by columns. Keys like primary and foreign keys link data across tables and ensure data integrity.

Uploaded by

gooda6201
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

DATABASE:

A database is an organized collection of structured information, or data, typically stored


electronically in a computer system. A database is usually controlled by a database
management system (DBMS).

What is a file system?


A file system defines how files are stored, and retrieved from a storage device.
Every time you open a file on your computer or smart device, your operating system uses its
file system internally to load it from the storage device.

Contents of a file can be texts, computer program code, comma separated values(csv), etc
likewise pictures, audios and videos, webpages are also files.

Limitations of a File System

Slow access time –


Direct access of files is very difficult and one needs to know the entire hierarchy of folders to
get to a specific file. This involves a lot of time.

Presence of redundant data –


The same data can be present in two or more files which takes up more disc space.

Inconsistent Data –
Due to data redundancy, same data stored at different places might not match to each
other.

Data Integrity Problems –


The data present in the database should be consistent and correct. To achieve this, the data
should must satisfy certain constraints.

Difficulty in recovery of corrupt data –


Recovery or backup of lost and corrupt data is nearly impossible in case of File Processing
System.

Problem in Concurrent Access –


When a number of users operates on a common data in database at the same time then
anomalies arise, due to lack of concurrency control.
Unauthorized Access –
Anyone who gets access to the file can read or modify the data.
KEYS IN A RELATIONAL DATABASE

Candidate Key:
A candidate key is a set of attributes (or attribute) which uniquely identify the tuples in
relation or table. As we know that Primary key is a minimal super key, so there is one and
only one primary key in any relationship but there is more than one candidate key can take
place. Candidate key’s attributes can contain a NULL value which opposes to the primary
key.
For example,
Student{ID, First_name, Last_name, Age}
Here we can see the two candidate keys ID and {First_name, Last_name, DOB}. So here,
there are present more than one candidate keys, which can uniquely identify a tuple in a
relation.

Difference between Primary Key and Foreign Key

Primary Key:
A primary key is used to ensure data in the specific column is unique. It is a column cannot
have NULL values. It is either an existing table column or a column that is specifically
generated by the database according to a defined sequence.

Example: Refer the figure –


STUD_NO, as well as STUD_PHONE both, are candidate keys for relation STUDENT but
STUD_NO can be chosen as the primary key (only one out of many candidate keys).

Foreign Key:
A foreign key is a column or group of columns in a relational database table that provides a
link between data in two tables. It is a column (or columns) that references a column (most
often the primary key) of another table.

Example: Refer the figure –


STUD_NO in STUDENT_COURSE is a foreign key to STUD_NO in STUDENT relation.
Let’s see the difference between Primary Key and Foreign Key:

S.NO. PRIMARY KEY FOREIGN KEY

A primary key is used to ensure A foreign key is a column or group of columns in


data in the specific column is a relational database table that provides a link
1 unique. between data in two tables.

It uniquely identifies a record in It refers to the field in a table which is the primary
2 the relational database table. key of another table.

Only one primary key is Whereas more than one foreign key are allowed in
3 allowed in a table. a table.

It is a combination of UNIQUE It can contain duplicate values and a table in a


4 and Not Null constraints. relational database.

5 It does not allow NULL values. It can also contain NULL values.

Its value cannot be deleted from


6 the parent table. Its value can be deleted from the child table.

It constraint can be implicitly It constraint cannot be defined on the local or


7 defined on the temporary tables. global temporary tables.
KEY CONCEPTS IN DBMS:

In order to efficiently manage data using a DBMS, let us understand certain key terms:
(A) Database Schema
Database Schema is the design of a database. It is the skeleton of the database that represents the
structure (table names and their fields/columns).
Database schema is also called the visual or logical architecture as it tells us how the data are
organised in a database.

(B) 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. For example, one can define the constraint that the column mobile
number can only have non-negative integer values of exactly 10 digits. Since each student shall have
one unique roll number, we can put the NOT NULL and UNIQUE constraints on the RollNumber
column. Constraints are used to ensure accuracy and reliability of data in the database.

(C) Meta-data or Data Dictionary


The database schema along with various constraints on the data is stored by DBMS in a database
catalogue or dictionary, called meta-data.

(D) Database Instance


When we define database structure or schema, state of database is empty i.e. no data entry is
there. After loading data, the state or snapshot of the database at any given time is the database
instance.

(E) Query
A query is a request to a database for obtaining information in a desired way. Query can be made to
get data from one table or from a combination of tables.

(F) Data Manipulation


Modification of database consists of three operations viz. Insertion, Deletion or Update.

(G) Database Engine


Database engine is the underlying component or set of programs used by a DBMS to create database
and handle various queries for data retrieval and manipulation.

RELATIONAL DATA MODEL:

In relational model, the data and relationships are represented by collection of inter-related tables.
Each table is a group of column and rows, where column represents attribute of an entity and rows
represents records. The table name and column names are helpful to interpret the meaning of
values in each row.[ In the formal relational model terminology, a row is called a tuple, a column
header is called an attribute, and the table is called a relation. ]

The data type describing the types of values that can appear in each column is represented by a
domain of possible values.
Domains: A domain is a set of values permitted for an attribute in a table. Domain is atomic. For
example, age can only be a positive integer. A data type or format is also specified for each domain.
It is possible for several attributes to have the same domain. The data type for Employee_ages is an
integer number.
Some examples of domains follow:
■ Mobile numbers, . The set of ten-digit phone numbers is valid
■Local_phone_number, The set of seven-digit phone numbers valid within a particular area code
■Social_security_numbers, . The set of valid nine-digit Social Security numbers.

Attribute: Each column in a Table. Attributes are the properties which define a relation. e.g.,
Student_Rollno, NAME,etc.

Tuple : It is nothing but a single row of a table, which contains a single record.

Relations: are in the table format. It is stored along with its entities. A table has two properties
rows and columns. Rows represent records and columns represent attributes.

Degree: The number of attributes in a relation is called the Degree of the relation.

Cardinality: Total number of rows present in the Table.

Null value: A field with a NULL value is a field with no value. Primary key can’t be a null value.

Primary key Attributes/columns

Foreign key
State
relation

Record/tuple/row

TABLE-1

1.Degree (Number of attributes)=6


2.Cardinality (Number of rows/tuples/records)=5

You might also like