Intro To Database
Intro To Database
1. Database:
A database is information that is set up for easy access, management and updating. Computer
databases typically store aggregations of data records or files that contain information, such as sales
transactions, customer data, financials and product information.
Or
It is a collection of data, or information, that is specially organized for rapid search and retrieval by a
computer. Databases are structured to facilitate the storage, retrieval, modification, and deletion of data in
conjunction with various data-processing operations. A database management system (DBMS) extracts
information from the database in response to queries.
2. Uses (e.g.):
• Improve business processes. Companies collect data about business processes, such sales,
order processing and customer service. They analyze that data to improve these processes,
expand their business and grow revenue.
• Keep track of customers. Databases often store information about people, such as
customers or users. For example, social media platforms use databases to store user
information, such as names, email addresses and user behavior. The data is used to
recommend content to users and improve the user experience.
• Secure personal health information. Healthcare providers use databases to securely store
personal health data to inform and improve patient care.
• Store personal data. Databases can also be used to store personal information. For
example, personal cloud storage is available for individual users to store media, such as
photos, in a managed cloud.
ACID Properties:
1. Atomicity: All changes to data are performed as if they are a single operation. That is, all
the changes are performed, or none of them are. For example, in an application that
transfers funds from one account to another, the atomicity property ensures that, if a debit
is made successfully from one account, the corresponding credit is made to the other
account.
2. Consistency: Data is in a consistent state when a transaction starts and when it ends. For
example, in an application that transfers funds from one account to another, the consistency
property ensures that the total value of funds in both the accounts is the same at the start
and end of each transaction.
3. Isolation: The intermediate state of a transaction is invisible to other transactions. As a
result, transactions that run concurrently appear to be serialized. For example, in an
application that transfers funds from one account to another, the isolation property ensures
that another transaction sees the transferred funds in one account or the other, but not in
both, nor in neither.
4. Durability: After a transaction successfully completes, changes to data persist and are not
undone, even in the event of a system failure. For example, in an application that transfers
funds from one account to another, the durability property ensures that the changes made
to each account will not be reversed.
2. Distributed: This database stores records or files in several physical locations. Data
processing is also spread out and
replicated across different parts of
the network. Distributed
databases can be homogeneous,
where all physical locations have
the same underlying hardware and
run the same operating systems
and database applications. They
can also be heterogeneous. In
those cases, the hardware, OS and
database applications can be
different in the various locations.
Cloud. These databases are built in a public, private or hybrid cloud for a virtualized
environment. Users are charged based on how much storage and bandwidth they use. They
also get scalability on demand and high availability. These databases can work with
applications deployed as software as a service.
5. Database Table:
A database table is a structure that organizes data into rows and columns – forming a grid. Tables
are similar to a worksheet in
spreadsheet applications. The rows run
horizontally and represent each record.
The columns run vertically and
represent a specific field. The rows and
columns intersect, forming a grid. The
intersection of the rows and columns
defines each cell in the table. The
header cell of a column usually displays
the name of the column. The column is
usually named to reflect the contents of
each cell in that column. For example, a
column name of FirstName could be
used to reflect that the cells will contain the first name of an individual. The rows don’t typically
have a header cell as such, but often the first column will contain a unique identifier – such as an
ID. This field is often assigned as the primary key, as a primary key requires a unique identifier
(i.e. the value of this field will be different for each record). This means that we can identify each
record by its ID (or other unique identifier). Therefore, tables can reference records in other tables
simply by referring to the record’s primary key value. In this case, the tables have a relationship.
This is where the relational part comes from relational database management systems.
6. Relationships among tables (entities):
1. One-to-one relationship: In a one-to-one relationship, a record in one table can
correspond to only one record in another table (or in
some cases, no records). One-to-one relationships
aren’t the most common, since in many cases you can
store corresponding information in the same table.
Whether you split up that information into multiple
tables depends on your overall data model and design
methodology; if you’re keeping tables as narrowly-
focused as possible (like in a normalized database),
then you may find one-to-one relationships useful.
Types:
“All Alternate Keys are Secondary keys but not all Secondary key are Alternate Keys.”
4. Join Dependency:
▪ The join decomposition is like a further generalization of the Multivalued
dependencies.
▪ In case the join of X1 and X2 over C is equal to relation X, then one can say that
there exists a join dependency (JD).
▪ Where X1 and X2 are the decompositions X1(A, B, C) and X2(C, D) of a given
relation X (A, B, C, D).
▪ Alternatively, X1 and X2 are lossless forms of decomposition of X.
▪ A JD ⋈ {X1, X2,…, Xn} holds over a relation X if X1, X2,….., Xn is a lossless-
join type of decomposition.
▪ The *(A, B, C, D), (C, D) happen to be a Join Dependency of X if the join of the
join’s attribute happens to be equal to the relation X.
▪ Here, we use the *(X1, X2, X3) to indicate that relation X1, X2, X3 and so on are
a Join Decomposition of X.
10.SQL: Structured Query Language, SQL is a database computer language designed for the retrieval
and management of data in a relational database like MySQL, MS Access, SQL Server, Oracle,
Sybase, Informix, Postgres etc. SQL stands for Structured Query Language. SQL was developed
in the 1970s by IBM Computer Scientists.
❖ Applications:
➢ Execute different database queries against a database.
➢ Define the data in a database and manipulate that data.
➢ Create data in a relational database management system.
➢ Access data from the relational database management system.
➢ Create and drop databases and tables.
➢ Create and maintain database users.
➢ Create view, stored procedure, functions in a database.
➢ Set permissions on tables, procedures and views.
❖ Sql Commands:
1. DDL (Data Definition Language):
It consists of the SQL commands that can be used to define the database schema.
It simply deals with descriptions of the database schema and is used to create and
modify the structure of database objects in the database. DDL is a set of SQL
commands used to create, modify, and delete database structures but not data.
These commands are normally not used by a general user, who should be accessing
the database via an application.
• CREATE: This command is used to create the database or its objects (like
table, index, function, views, store procedure, and triggers).
• DROP: This command is used to delete objects from the database.
• ALTER: This is used to alter the structure of the database.
• TRUNCATE: This is used to remove all records from a table, including
all spaces allocated for the records are removed.
• COMMENT: This is used to add comments to the data dictionary.
11.References:
1. https://in.indeed.com/career-advice/career-development/what-is-relationship-in-database
2. https://database.guide/what-is-a-table/
3. https://www.ibm.com/docs/en/cics-ts/5.4?topic=processing-acid-properties-transactions
4. https://www.metabase.com/learn/databases/table-relationships
5. https://prepinsta.com/dbms/recursive-relationship/
6. https://techdifferences.com/difference-between-cardinality-and-modality.html
7. https://www.javatpoint.com/dbms-normalization