0% found this document useful (0 votes)
16 views6 pages

CH 7DATABASE CONCEPTS 240927 195716

Uploaded by

fatihmehmet1117
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)
16 views6 pages

CH 7DATABASE CONCEPTS 240927 195716

Uploaded by

fatihmehmet1117
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
You are on page 1/ 6

XII COMPUTER SCIENCE

DATABASE CONCEPTS - MYSQL


DATABASE:
A database is a structured and efficient system for storing, organizing, and managing data, allowing easy access,
modification, and analysis of information while maintaining data integrity and security.
DATABASE MANAGEMENT SYSTEM:
A DBMS is a set of programs that enables the user to define, create and maintain the database and provides controlled
access to it. Eg: Mysql , Oracle, Ms-Access.
Advantages of database systems are as follows:

• Reduce data redundancy (data duplication) to a large extent


• Control data inconsistency to a large extent
• Facilitate sharing of data
• Data integrity- Maintains accurate and consistent data.
• Centralized databases can ensure data security
• Backup and recovery
• Concurrency control- Multiple users can access the data at the same time.
NEED FOR DATABASES:
Need for databases arose in response to the traditional file system and the limitations that came with it.
limitations of a file system:
1. **Difficulty in Access: **
- Files need special programs to get data.
- Writing custom programs for access can be hard.
2. **Data Redundancy: **
- Same data repeated in different files.
- Makes data storage inefficient.
- Can cause data inconsistencies.
3. **Data Inconsistency: **
- Data mismatch in different places.
- Changes need careful updates everywhere.
- Inconsistent data leads to confusion.
4. **Data Isolation: **
- No connections between different data files.
- Hard to access related information.
- Files might have different formats.
5. **Data Dependence: **
- Data format changes need changes in programs.
- Programs tied to file structure.
- Updating files means updating many programs.
6. **Controlled Data Sharing: **
- Hard to limit who can access and modify data.
- Basic file systems lack advanced access controls.
- Need more layers for secure data sharing.
These limitations show why traditional file systems can be challenging to manage as data and usage complexity grow.
Modern databases and systems address these issues better.
RELATIONAL DATA MODEL:
A data model refers to a set of concepts to describe the structure of a database, and certain constraints (restrictions)
that database should obey. In relational data model, the data is organized into tables (i.e. rows and columns) with
relationships to each other. These tables are called relations.
XII COMPUTER SCIENCE

Relation: A table storing data containing rows and columns


Domain: A pool/set of values from which the actual values appears in a row and column.
Tuple: A row of relation, also called a record Attribute: A column of a relation, also known as field
Cardinality: Number of rows (tuples) in a relation
Degree: Number of columns (attributes) in a relation.
Primary Key: A set of one or more attributes that can uniquely identify tuples within the relation.
Candidate Key: All attribute combinations inside a relation that can serve as primary key are candidate keys as these
are candidate for primary key positions.
Alternate Key: A candidate key that is not primary key is called an alternate key.
Foreign Key: A non-key attribute, whose values are derived from the primary key of some other table, is known as
foreign key of its current table.

REFERENTIAL INTEGRITY:
A referential integrity is a system of rules that database management system uses to ensure that relationships
between records in related tables are valid, and that users don't accidently delete or change related data.
STRUCTURED QUERY LANGUAGE:
SQL is a query language used by major relational DBMSs such as Mysql, Oracle, SQL server etc. SQL statements are
not case sensitive. SQL is not platform dependent and can be used on all types of devices.
CLASSIFICATION OF SQL STATEMENTS:
Structured Query Language Provides many different types of commands used for different purposes. SQL commands
can be mainly divided into following categories:
1. DDL (Data Definition Language): Commands that allow you to perform task related to data definition e.g.
Creating, Altering and Dropping Granting and Revoking Privileges and Roles Maintenance commands
2. DML (Data Manipulation Language): Commands that allow you to perform data manipulation e.g.
• Retrieving (selecting)
• Insertion
• Deletion
• Modification
3. TCL (Transaction Control Language): Commands that allow you to manage and control the transactions. A
transaction is one complete unit of work involving many steps e.g.
• Making changes to database, permanent
XII COMPUTER SCIENCE

• Undoing changes to database, permanent


• Creating save points.
• Setting properties for current transactions
DATA MANIPULATION LANGUAGE (DML):
SELECT: Retrieves data from a database table.
INSERT: Adds new records to a table.
UPDATE: Modifies existing records in a table.
DELETE: Removes records from a table.
DATA DEFINITION LANGUAGE (DDL):
CREATE TABLE: Creates a new table with specified columns and data types.
ALTER TABLE: Modifies the structure of an existing table (e.g., adding or dropping columns).
DROP TABLE: Deletes a table and its data.
DATATYPES:
CHAR(n): Fixed-length text, up to 'n' characters. (string 0-255)

VARCHAR(n): Variable-length text, up to 'n' characters. (string 0-255)

INT: Whole numbers, no decimal places.

FLOAT: Decimal numbers with a wide range.

DATE: Calendar dates without time. YYYY-MM-DD

SQL CONSTRAINTS:

A constraint is a condition or check applicable on a field (column) or set of fields.


• NOT NULL: Ensures that a column cannot have NULL value.
CREATE TABLE Customer (SID integer NOT NULL,Last Name varchar (30) NOT NULL,First Name varchar
(30));
• DEFAULT: Provides a default value for a column when none is specified.
CREATE TABLE Student (StudentID integer,Last Name varchar (30), First Name varchar (30), Score DEFAULT
80);
• UNIQUE: Ensures that all values in a column are different.
CREATE TABLE Student (StudentID integer UNIQUE, Last Name varchar (30), First Name varchar (30));
• CHECK: Makes sure that all values in a column satisfy certain criteria.
CREATE TABLE Student (StudentID integer CHECK (StudentID> 0) Last Name varchar (30) NOT NULL, First
Name varchar (30));
• PRIMARY KEY: Used to uniquely identify a row in a table.
CREATE TABLE Student (StudentID integer PRIMARY KEY,Last Name varchar (30),First Name varchar (30));
• FOREIGN KEY: Used to ensure referential integrity of the data.
CREATE TABLE Orders (Order_Id integer PRIMARY KEY,Order_Date date,Customer_SID integer, Amount
double,FOREIGN KEY (Customer_SID) references Customer (SID));
XII COMPUTER SCIENCE

Note: A constraint can be applied to a column to a group of columns. When it is applied to a group of columns, it is
called table constraint.
XII COMPUTER SCIENCE
XII COMPUTER SCIENCE

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy