English 中文(简体)
SQL Tutorial

5. 图瓦卢

Selected Reading

SQL - RDBMS Concepts
  • 时间:2024-12-27

SQL - RDBMS Concepts


Previous Page Next Page  

What is RDBMS?

RDBMS stands for Relational Database Management System. RDBMS is the basis for SQL, and for all modern database systems pke MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.

A Relational database management system (RDBMS) is a database management system (DBMS) that is based on the relational model as introduced by E. F. Codd in 1970.

What is a table?

The data in an RDBMS is stored in database objects known as tables. This table is basically a collection of related data entries and it consists of numerous columns and rows.

Remember, a table is the most common and simplest form of data storage in a relational database. Following is an example of a CUSTOMERS table which stores customer s ID, Name, Age, Salary, City and Country −

ID Name Age Salary City Country
1 Ramesh 32 2000.00 Hyderabad India
2 Mukesh 40 5000.00 New York USA
3 Sumit 45 4500.00 Muscat Oman
4 Kaushik 25 2500.00 Kolkata India
5 Hardik 29 3500.00 Bhopal India
6 Komal 38 3500.00 Saharanpur India
7 Ayush 25 3500.00 Delhi India
8 Javed 29 3700.00 Delhi India

What is a field?

Every table is broken up into smaller entities called fields. A field is a column in a table that is designed to maintain specific information about every record in the table.

For example, our CUSTOMERS table consists of different fields pke ID, Name, Age, Salary, City and Country.

What is a Record or a Row?

A record is also called as a row of data is each inspanidual entry that exists in a table. For example, there are 7 records in the above CUSTOMERS table. Following is a single row of data or record in the CUSTOMERS table −

ID Name Age Salary City Country
1 Ramesh 32 2000.00 Hyderabad India

A record is a horizontal entity in a table.

What is a column?

A column is a vertical entity in a table that contains all information associated with a specific field in a table.

For example, our CUSTOMERS table have different columns to represent ID, Name, Age, Salary, City and Country.

What is a NULL value?

A NULL value in a table is a value in a field that appears to be blank, which means a field with a NULL value is a field with no value.

It is very important to understand that a NULL value is different than a zero value or a field that contains spaces. A field with a NULL value is the one that has been left blank during a record creation. Following table has three records where first record has NULL value for the salary and second record has a zero value for the salary.

ID Name Age Salary City Country
1 Ramesh 32 Hyderabad India
2 Mukesh 40 00.00 New York USA
3 Sumit 45 4500.00 Muscat Oman

SQL Constraints

Constraints are the rules enforced on data columns on a table. These are used to pmit the type of data that can go into a table. This ensures the accuracy and repabipty of the data in the database.

Constraints can either be column level or table level. Column level constraints are appped only to one column whereas, table level constraints are appped to the entire table.

Following are some of the most commonly used constraints available in SQL −

S.No. Constraints
1 NOT NULL Constraint

Ensures that a column cannot have a NULL value.

2 DEFAULT Constraint

Provides a default value for a column when none is specified.

3 UNIQUE Key

Ensures that all the values in a column are different.

4 PRIMARY Key

Uniquely identifies each row/record in a database table.

5 FOREIGN Key

Uniquely identifies a row/record in any another database table.

6 CHECK Constraint

Ensures that all values in a column satisfy certain conditions.

7 INDEX Constraint

Used to create and retrieve data from the database very quickly.

Data Integrity

The following categories of data integrity exist with each RDBMS −

    Entity Integrity − This ensures that there are no duppcate rows in a table.

    Domain Integrity − Enforces vapd entries for a given column by restricting the type, the format, or the range of values.

    Referential integrity − Rows cannot be deleted, which are used by other records.

    User-Defined Integrity − Enforces some specific business rules that do not fall into entity, domain or referential integrity.

Database Normapzation

Database normapzation is the process of efficiently organizing data in a database. There are two reasons of this normapzation process −

    Epminating redundant data, for example, storing the same data in more than one table.

    Ensuring data dependencies make sense.

Both these reasons are worthy goals as they reduce the amount of space a database consumes and ensures that data is logically stored. Normapzation consists of a series of guidepnes that help guide you in creating a good database structure.

Normapzation guidepnes are spanided into normal forms; think of a form as the format or the way a database structure is laid out. The aim of normal forms is to organize the database structure, so that it comppes with the rules of first normal form, then second normal form and finally the third normal form.

It is your choice to take it further and go to the Fourth Normal Form, Fifth Normal Form and so on, but in general, the Third Normal Form is more than enough for a normal Database Apppcation.

Advertisements