DBMS NOTES
DBMS NOTES
Key Points
Data is a raw and unprocessed form of facts and figures.
Information is a processed and meaningful data that can be easily interpreted.
Database is a collection of data, which is stored in a systematic manner, i.e., in the form of tables.
A table holds information in the form of rows and columns.
In a database table, rows are referred to as records or tuples and columns as fields or attributes.
A record is set of related information that belongs to a particular instance of an object.
A field describes a specific property of a record. It is also known as an attribute.
A Database Management System (DBMS) is a computerised record keeping system or a software that
enables you to create, store, modify, and extract information from a database.
A Relational Database Management System (RDBMS) is a type of DBMS software that uses relational
database (RDB) model for its database.
A relational model enables the users to store data in several tables.
A primary key is a set of one or more fields that uniquely identify each record in a table. It does not contain
any duplicate data or NULL value. A table can have only one primary key.
A composite key or composite primary key refers to a combination of two or more attributes (fields) that
uniquely identify the records in a table. It may be a candidate or primary key.
A foreign key consists of one or more fields whose value matches a primary key in another table. It acts as a
cross-reference between the tables.
There are four main objects in any database - Tables, Queries, Forms, and Reports. A data type determines
what type of data you can enter into a field.
Referential Integrity (RI) is a rule in RDBMS. It states that a foreign key must have a matching primary key,
i.e., all its references must be valid and the users cannot accidentally delete or amend data.
The three different types of relationships that can exist between a given pair of tables are one-to-One, One-
to-Many, and Many-to-Many.
In a One-to-One relationship, a record in a table can have only one matching record in another table.
In a One-to-Many relationship, a record of a table is associated with several matching records in another.
However, the record of the second table is associated with only one record in the first table.
In a Many-to-Many relationship, one record is associated with several records in another table, and vice
versa.
In RDBMS, a query is a database object that enables you to retrieve records from one or more tables of a
database or different databases that meet a specific condition or criteria. MS Access provides various built-in
functions to perform calculations on query data.
Structured Query Language (SQL) is the language used in RDBMS for writing queries.
Data Definition Language (DDL) commands are used to define and modify the structure of a database. Some
commonly used DDL commands are Create, Alter, Drop, Truncate, and Rename.
Data Manipulation Language (DML) commands help in retrieval, insertion, deletion, and modification of the
information present in the database. Some commonly used DML commands are Select, Insert, Update, and
Delete.
Database is a collection of data, which is stored in a systematic manner, i.e., in the form of tables so that
one can retrieve and manipulate the information quickly and efficiently from a large set of data.
The Database Management System (DBMS) is a computerised record keeping system or a software that
enables you to create, store, modify, and extract information from a database. The Relational Database
Management System (RDBMS) is a type of the DBMS software that uses the Relational Database (RDB)
model for its database. A relational model enables the users to store data in several tables.
Tuples: All the rows (consists of a set of related information that belongs to a particular object) in a
table/database are called tuples or records. Attributes: An attribute is a piece of information about an
object. All the columns in a table/database are called attributes.
A primary key is a set of one of more fields that uniquely identifies each record in a table. It does not
contain any duplicate data. A table can have only one primary key.
The value in the primary key field is different for every tuple and thus helps in uniquely identifying the
records. A foreign key is a field or set of fields that is used to establish a relation between the two tables. In
other words, it consists of one or more fields whose value matches with a primary key in another table.
Basically, a foreign key in one table is used to point at a primary key in another table. It acts as a cross-
reference between the tables.
A composite key or composite primary key refers to a combination of two or more attributes (fields) that
uniquely identify the records in a table. It may be a candidate key or primary key. For example, In the
Customer table of Dominos database, the CustOrder_ID field alone cannot become a primary key as many
products can be purchased by the same customer, thus the same customer can have multiple entries.
Following are the different database objects:
Tables store data items in the form of rows and columns.
Queries are used to retrieve a specific data from the tables of a database.
Forms are the user-friendly interfaces that facilitate the process of inserting,editing, deleting, and updating
the data in tables and queries.
Reports are used to display the selected data in a printable format.
Data types determine what type of data you can enter into a field.
Text [VARCHAR] data type a variable length field type, which is used to store character or string values.
The Table Data view is the default view of LibreOffice Base. In this view, you can enter and navigate the
records. In Table Design view, you can create a table by defining the field names and field types. This view
also allows you to edit the structure of the created tables.
Select the table in a database, right-click on it, and select the Edit option.
The selected table will be opened in the Design View.
Change the field name, field type or properties of the field as per your requirement.
After making the required changes, click on the Save button.
Short Notes
1 .To sort the records of a table in descending order, first select a field according to which you want to sort the data.
Click on the Sort in Descending Order button on the Table Data toolbar. Data will be sorted on the basis of the
selected field.
2. Referential Integrity (RI) is a rule in RDBMS. It states that a foreign key must have a matching primary key, i.e., all
its references must be valid and the users cannot accidentally delete or amend the data. It ensures the accuracy and
consistency of the data within a relationship, and prevents the users to enter the inconsistent data.
3. Following are different types of relationships:
• One-to-One • One-to-Many • Many-to-Many
4. Students and Courses tables are best example of a many-to many relationship. A student can register for many
courses, and a same course can be opted by many students.
5. A query is a database object that enables you to retrieve records from one or more tables of the database or
different databases that meet a specific condition or criteria.
6. Following are the two queries views:
• Query Design View • The SQL View
7. The Query Wizard guides you to create a query based on selected table. It is the easiest method for beginners. The
Query Design View gives you more control over a query. It allows you to create a query from the scratch.
8. SQL is a language that allows you to make queries to define the data structure and manipulate the data in the
database. A user can create and manipulate (insert new data, delete data, select and update data) the database
anytime by using the Structured Query Language (SQL) commands.
9. DDL commands are used to define and modify the structure of a database whereas DML commands allow the
users to manipulate data in the database.
10. A form holds different fields of a table that you use to enter and modify the data in the database. Using form,
you can add or edit one record at a time. It is a convenient and an interactive way of entering data, but not an
appropriate tool for every data entry.
11. To launch the Form Wizard, click on the Forms option in the Database Objects pane.Then, select the Use Wizard
to Create Form option in the Tasks pane. The Form Wizard will open.
12. A report is a summary of your database. It is an effective way to organise and summarise the data for viewing
and printing. It consists of information obtained from tables or queries, and presented as per the user's
requirements.
13. A static report always displays the same data from the time when the static report was created. A dynamic
report generates the result of the report from the current table data. This means that if you have some updated data
in the table that feeds the report, then the report will change accordingly.
15. Tuples: All the rows (consists of a set of related information that belongs to a particular object) in a
table/database are called tuples or records. Attributes: An attribute is a piece of information about an object. All the
columns in a table/database are called attributes.
16. A composite primary key refers to a combination of two or more attributes (fields) that uniquely identify the
records in a table.
17. A relational model enables the users to store data in several tables, and whenever the data is need, it can be
retrieved easily by establishing a relationship among them.
Data Definition Language (DDL)-
CREATE
CREATE It is used to create a new table in the database.
Syntax:
CREATE TABLE TABLE_NAME (COLUMN_NAME DATATYPES[ , ]);
Example:
CREATE TABLE EMPLOYEE(Name VARCHAR2(20), Email VARCHA R2(100), DOB DATE);
Drop
Drop: It is used to delete both the structure and record stored in the table.
Syntax:
DROP TABLE ;
Example:
DROP TABLE EMPLOYEE;
Syntax:
ALTER TABLE table_name ADD column_name COLUMN-definition; ALTER TABLE MODIFY(COLUMN DEFINITION );
Example:
ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20)); ALTER TABLE STU_DETAILS MODIFY (NAME
VARCHAR2(20));
TRUNCATE
TRUNCATE: It is used to delete all the rows from the table and free the space containing the table.
Syntax:
TRUNCATE TABLE table_name;
Example:
TRUNCATE TABLE EMPLOYEE;
INSERT
INSERT: The INSERT statement is a SQL query. It is used to insert data into the row of a table.
Syntax:
INSERT INTO TABLE_NAME (col1, col2, col3,.... col N)
VALUES (value1, value2, value3, valueN);
OR
INSERT INTO TABLE_NAME VALUES (value1, value2, value3, valueN);
Example:
INSERT INTO XYZ (Author, Subject) VALUES ("Sonoo", "DBMS");
UPDATE
Update: This command is used to update or modify the value of a column in the table.
Syntax:
UPDATE table_name SET [column_name1= value1,...column_n ameN = valueN] [WHERE CONDITION]
Example:
UPDATE students
SET User_Name = 'Sonoo' WHERE Student_Id = '3'