Basics Flashcards
DataBase
The database is a collection of inter-related data which helps in efficient retrieval, insertion, and deletion of data from the database and organizes the data in the form of tables, views, schemas, reports, etc.
DDL
DDL is the short name of Data Definition Language, which deals with database schemas and descriptions, of how the data should reside in the database.
DDL commands
Data definition language
CREATE: to create a database and its objects like (table, index, views, store procedure, function, and triggers)
ALTER: alters the structure of the existing database
DROP: delete objects from the database
TRUNCATE: remove all records from a table, including all spaces allocated for the records are removed
COMMENT: add comments to the data dictionary
RENAME: rename an object
It helps in the creation, modification, and removal of definitions that define the organization of data in the database.
DML
DML is the short name of Data Manipulation Language which deals with data manipulation and includes most common SQL statements such SELECT, INSERT, UPDATE, DELETE, etc., and it is used to store, modify, retrieve, delete and update data in a database.
DBMS
Database Management System: The software which is used to manage the database is called Database Management System (DBMS). For Example, MySQL, Oracle, etc. are popular commercial DBMS used in different applications
Why not File System?
Redundancy of data
Inconsistency of Data
Difficult Data Access
Unauthorized Access
No Concurrent Access( access of same data by multiple users at the same time is known as concurrency)
No Backup and Recovery
Data Independence
Data independence means a change of data at one level should not affect another level.
Physical Data independence
Physical Data Independence: Any change in the physical location of tables and indexes should not affect the conceptual level or external view of data. This data independence is easy to achieve and implemented by most of the DBMS.
The physical level of a database describes how the data is being stored in secondary storage devices like disks and tapes
Conceptual data independence
Conceptual Data Independence: The data at conceptual level schema and external level schema must be independent.
This means a change in conceptual schema should not affect external schema.
e.g.; Adding or deleting attributes of a table should not affect the user’s view of the table. But this type of independence is difficult to achieve as compared to physical data independence because the changes in conceptual schema are reflected in the user’s view.
Entity and Entity set
An Entity is an object of Entity Type and a set of all entities is called an entity set. e.g.; E1 is an entity having Entity Type Student and the set of all students is called Entity Set.
Attributes are the properties that define the entity type. For example, Roll_No, Name, DOB, Age, Address, Mobile_No are the attributes that define entity type Student.
Composite Attribute
An attribute composed of many other attributes is called a composite attribute. For example, the Address attribute of student Entity type consists of Street, City, State, and Country.
Relationship between entities
A relationship type represents the association between entity types. For example, ‘Enrolled in’ is a relationship type that exists between entity type Student and Course.
Cardinality
The number of times an entity of an entity set participates in a relationship set is known as cardinality.
types:
One to one
many to one
many to many
Participation Constraint:
Total Participation – Each entity in the entity set must participate in the relationship. If each student must enroll in a course, the participation of the student will be total.
Partial Participation – The entity in the entity set may or may NOT participate in the relationship. If some courses are not enrolled by any of the students, the participation of the course will be partial.
Weak Entity
an entity type has a key attribute that uniquely identifies each entity in the entity set. But there exists some entity type for which key attributes can’t be defined. These are called the Weak Entity types
For example, A company may store the information of dependants of an Employee. But the dependents don’t have existed without the employee. So Dependent will be weak entity type and Employee will be Identifying Entity type for Dependant.
The participation of the weak entity type is always total.