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

MySQL Theory

The document provides an overview of databases, highlighting the role of Database Management Systems (DBMS) in managing data and the advantages of using database systems over file systems. It explains key concepts such as levels of abstraction, SQL commands, database terminologies, keys, and constraints. Additionally, it outlines the functions of Data Definition Language (DDL) and Data Manipulation Language (DML) in database operations.
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

MySQL Theory

The document provides an overview of databases, highlighting the role of Database Management Systems (DBMS) in managing data and the advantages of using database systems over file systems. It explains key concepts such as levels of abstraction, SQL commands, database terminologies, keys, and constraints. Additionally, it outlines the functions of Data Definition Language (DDL) and Data Manipulation Language (DML) in database operations.
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Introduction To Database

Database is a very large integrated collection of


data, which models real-world enterprise. It
possesses entities and relationships.

DBMS (Database Management System)


DBMS is a software package designed to store and
manage databases. Eg:-
• Banking: All Transactions
• Airlines: Reservations, Schedules
• Universities: Registration, Grades

Advantages of Database Systems


• No data redundancy and inconsistency
• No difficulty in accessing data
• No integrity problems
• No Security Problems
• No need to write a new program to carry out
each new task.
• Easy to add or edit new constraints.

For Drawbacks of File Systems, write the exact


opposite of the above.

Levels of Abstraction
• Views describe how users see the data
• Conceptual Schema defines logical structure
• Physical Schema describes the files and indexes
used.
• Schemes are defined using DDL (Data Definition
Language)
• Data is modified/queried by DML (Data
Manipulation Language)
• There are three levels of abstraction:-
◦ Physical Level:- Describes storage of record
◦ Logical Level:- Describes relationships and
data in a database.
◦ View Level: Application programs hide details
and information.

Instances and Schemas


Schema is the logical structure of the database.
• Physical Schema: Describes design at physical
level
• Logical Schema: Describes design at the
logical level.
• It is analogous to the variable value and type.

SQL (Structured Query Language)


SQL is a standard language for storing, manipulating
and retrieving data in databases.

DDL (Data Definition Language) is the


specification notation for defining the database
schema.

Eg:- CREATE TABLE todo_list (


task varchar(25),
time varchar(20)
);

DDL Commands are:-


• CREATE:- Creates a table or databse
• ALTER:- Used for alteration
• DROP:- Used to drop a table
• RENAME:- Used to rename a table.

DML (Data Manipulation Language) is used for


accessing and manipulating data organized by
appropriate data model. Eg:- SQL.

DML commands include:-


• INSERT:- Used to add new data in table.
• UPDATE:- Used to update existing data in table.
• DELETE:- Used to delete records from table
• SELECT:- Retrieves information from database
table.

Database Terminologies
• Relation: A table in a database
• Tuple/Record: A row in a table
• Field/Attributes: A column in a table
• Domain: Possible pool of values for a specific
column
• Degree: Number of columns in a table at that
instance
• Cardinality: Number of rows in a table at that
instance.

Keys
Key is used to uniquely identify any record in a table
or establish relationships between tables.

• Primary Key
◦ It uniquely identifies each record in a table.
◦ It should contain unique values and not null
values
◦ Each table can have only one primary key.

• Candidate Key
◦ It is a super key with no repeated attributes.
◦ Primary key should be selected from the
candidate keys.
◦ A table can have multiple candidate keys.

• Alternate Key
◦ They are candidate keys which are not primary
keys.
◦ Database administrator chooses a different
key as the primary key.

Constraints
UNIQUE:- Ensures all values in a column are
different. It allows one null value
NOT NULL:- Ensures that all values in a column are
not null. Thus, it makes this column to be mandatory.
DEFAULT:- It is the value added to each row in a
column if no other value is specified.
CHECK:- Ensures that all values in a column satisfy
certain condition(s).

Basic MySQL Operations


Write any 6 commands in SQL.

You might also like