Overview On Database: SQL, DBMS, Constraint, Statement – Devstringx
What is a Database?
A database is a place where we store data in the form of tables. Data means information that is very useful. A database is also known as the collection of one or more tables.
Table – It is a collection of rows and columns.
- A column is also known as a field/attribute.
- A record is also known as a row/tuple.
- A table is also known as an entity/relation.
Note:- If we install any database-related software – we can create our own databases, we can create our own tables, and store the data inside them.
When we install any database software – a part of the hard disk will designate/reserved to perform database-related activities.
A database also contains other database objects like views, indexes, stored procedures, functions, triggers, etc, apart from tables. Some of the database software we have like, Oracle, SQL Server, DB2, Sybase, Informix, MySQL, MS – Access, Foxbase, and FoxPro Among the above database software – some of them are DBMS and some of them are RDBMS
The software which is widely used is Oracle. The different versions of Oracle starting from the earliest to the latest are – Oracle 2, Oracle 3, Oracle 4, Oracle 5, Oracle 6, Oracle 7, Oracle 8i, Oracle 9i, and Oracle 10g,
The latest to hit the market is Oracle 11g. here i ‟ stands for Internet and g ‟ stands for Grid / Grid computing.
What Is SQL (Structured Query Language)?
The SQL language to talk to a database or to access the database. It is language is a way of communicating with our data, the query will tell about the rules of the language, and how you can use that language to communicate with the data.
To work with SQL, a DB software ->RDBMS is required.
SQL is not case-sensitive.
What Is DBMS?
DBMS – Stands for Database Management System
It is a database software that allows storing data in the form of tables.
Examples of DBMS – are FoxPro, FoxBase, Database
What Is RDBMS?
What Are Constraints?
A constraint is a condition that restricts the invalid data inside the table. A constraint can provide for columns of a table.
Types of Constraints
- NOT NULL
- UNIQUE
- PrimaryKey
- ForeignKey
- Check
- NOT NULL
NOT NULL ensure at least some of the value should be present in a column.
- UNIQUE
®It does not allow any duplicates in a column.
®UNIQUE column can take multiple NULL.
- PrimaryKey
®PK is a combination of NOT NULL and UNIQUE.
®Only one PK allows in a table.
®PK identifies a record uniquely in the table.
®Creation of PK is not mandatory, still, it is highly recommended to create.
- ForeignKey
®FK creates relationship b/n any two tables
®It is also known as referential integrity constraints.
®FK create on the child table.
®FK takes both NULL and duplicate values.
®To create FK, the master table should have PK defined on the common column of the master table.
®We can have more than one FK in a table.
- CHECK
It uses to provide additional validation as per customer requirements.
Example–
- sal>0
- empnumshouldstartwith1
- commissionshouldbebetween2000&6000
What Are Statements?
It helps to create the table and insert the data.
There is some command of statements:
>CREATE :
SYNTAX: CREATE TABLE table_name
>RENAME:
SYNTAX: RENAME current_table_name TO New_table_name;
>ALTER:
SYNTAX:
1. TO ADD A COL: ALTER TABLE table_name
ADD COLUMN_NAME DATATYPE[NULL/NOT NULL];
2. TO DROP A COL: ALTER TABLE table_name
DROP COLUMN COLUMN_NAME ;
>TRUNCATE:
SYNTAX: TRUNCATE TABLE table_name;
>DROP:
SYNTAX: DROP TABLE table_name;
Now will discuss the project, first need to download “Microsoft SQL Server Management Studio”
Once you download and Install then you will get a window like this:
- Click on Connect->Database Engine
- Enter the Server name.
- Enter Login user id.
- Enter password.
- Click on Connect button.
To see the data available in the table:
- Expand your database (in my case is “test”).
- Expand Tables.
- Right-click on the tables for which you want to see the data.
Click on “Select Top 1000 Rows”
Then you will get all data available in that table.
If you want to go a specific data just write down the query
and click on execute button
Once the query will execute successfully then you will get that specific data where AuthorisationFlowId is 5 in the AuthorisationFlow table.
Conclusion:
In conclusion, a database is a more efficient mechanism to store and organize data compared to spreadsheets. It allows the storage of data at a centralized place where multiple users can access, modify and quickly share with anyone.
Related Articles–