0% found this document useful (0 votes)
33 views12 pages

Session 9

The document discusses key concepts related to relational databases and SQL. It explains that a database contains organized data and a DBMS provides mechanisms for storing, accessing, and modifying data for users independently of its internal structure. Relational databases organize data into tables composed of rows and columns, with each table having a primary key to uniquely identify rows. Foreign keys help maintain referential integrity by linking data between tables and allowing data to be joined. The document also describes one-to-one, one-to-many, and many-to-many relationship types that can exist between tables.

Uploaded by

Syed Aamir Ali
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views12 pages

Session 9

The document discusses key concepts related to relational databases and SQL. It explains that a database contains organized data and a DBMS provides mechanisms for storing, accessing, and modifying data for users independently of its internal structure. Relational databases organize data into tables composed of rows and columns, with each table having a primary key to uniquely identify rows. Foreign keys help maintain referential integrity by linking data between tables and allowing data to be joined. The document also describes one-to-one, one-to-many, and many-to-many relationship types that can exist between tables.

Uploaded by

Syed Aamir Ali
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Session 9

Database & SQL


Database & SQL
• A database is an organized collection of data.
• A database management system (DBMS)
provides mechanisms for storing, organizing,
retrieving and modifying data for many users.
Database management systems allow access
to and storage of data independently of the
internal representation of the data.
Database & SQL
• Relational Databases
• A relational database is a logical
representation of data that allows the data to
be accessed independently of its physical
structure. A relational database organizes data
in tables
Database & SQL
• Tables are composed of rows and columns in
which values are stored.
• The table's primary key a column (or group of
columns) in a table that requires a unique
value that cannot be duplicated in other
rows.
• A primary key that is composed of two or
more columns is known as a composite key.
Database & SQL
Database & SQL
• A feature provided by
relational database management systems (RD
BMS's)
that prevents users or applications from
entering inconsistent data. Most RDBMS's
have various referential integrity rules that
you can apply when you create a relationship
between two tables.
Database & SQL
• Foreign Keys
• A foreign key helps maintain the Rule of
Referential Integrity every foreign key value
must appear as another table's primary key
value
• Foreign keys also allow related data in
multiple tables to be selected from those
tables this is known as joining the data.
Database & SQL
• Referential integrity would prevent you from
adding a record to Table B that cannot be
linked to Table A.

Table A Table B
Std ID (PK) SNO(PK)
StdName StdID(FK)
StdClass StdClass
Database & SQL
• Whenever you delete a record from Table A,
any records in Table B that are linked to the
deleted record will also be deleted. This is
called cascading delete.
• Whenever you modify the value of a linked
field in Table A, all records in Table B that are
linked to it will also be modified accordingly.
This is called cascading update.
Database & SQL
• One-to-One Relationships
• One-to-one relationships occur when there is
exactly one record in the first table that
corresponds to exactly one record in the
related table.
Database & SQL
• One-to-many and many-to-one relationships
• An employee can work in only one
department; this relationship is single-valued
for employees. On the other hand, one
department can have many employees; this
relationship is multi-valued for departments.
The relationship between employees (single-
valued) and departments (multi-valued) is a
one-to-many relationship.
Database & SQL
• Many-to-many relationships
• A relationship that is multi-valued in both
directions is a many-to-many relationship. An
employee can work on more than one project,
and a project can have more than one
employee.

You might also like