Data : Raw fact and figure is called data or raw data
Info : Combnation of meta data and data is called info
Meta data: Context/ data discription/ data dictionary
Database : collection fo related tables (In database table is known as relation)
DBS : Database system (DBA,DBMS,DS)
DBMS : System that manages database is called Database Managment System (DBMS)
DBA : Database Administration ( User that interacts with DBS )
(Database System)DBS ->(DBA -> DBMS -> Database )
Table/Relation -> Intersection between Rows and Column
FPS: File Processing system(old database system)
Database terminologies
1) Entity: A real-world object or concept that can be distinctly identified and stored in a database.
2 ) Attribute: A property or characteristic of an entity, represented as a column in a table.
3) Relation: A table in a relational database containing rows (tuples) and columns (attributes).
4) Relationship: An association between two or more entities. ( There are 4 type of relationships One to
One , One to Many, Many to One , Many to Many)
5) Tuple: A single row in a table, representing one record.
6) Domain : set of all values associated with single attribute. (Eg: The domain of Age could be integers
between 1 and 100.)
7) Cardinality: The number of tuples (rows) in a relation (table).
8) Cell: The intersection of a row and a column in a table, containing a single value.
9) Constraint: A rule enforced on data in a database to ensure accuracy and integrity.
10) Views: A virtual table based on a query, displaying data from one or more tables without storing it
physically.
Relational Keys
Relational keys -> there are two types of 1)keys simple key, 2)
Simple key ->those keys which are made of one attributes
Composite key -> those keys which are made of more than one attributes
Further type of keys in database
1)Candidate key ( Key that is used to achieve uniqueness,/ A set of attributes that can uniquely identify a
tuple.)
2)Super key ( Key that is unique and irreduicable, every super key is a candidate key)
3)Primary key ( Key that is unique , irreduicable and not null / A unique identifier for each tuple in a
table.)
4)Alternate key ( Key that can be primry key but we didn't make it or Other than primary key is called
Alternate key)
5)Foreign key ( Key that is Primary key of another relation / An attribute in one table that references the
primary key in another table.)
Schema -> Schema is the blueprint or sturucture that defines the format and content of data.
Key attributes -> Those attributes which are used to maintain relationship between relations in a
databases.
Genral order of Clause
SELECT
FROM
WHERE
GROUP BY
ORDER BY
Column expressions has
Attributes
Operators
String constant
Aggregate Functions
Alias
String constant : " String Constant"
Pipe Operator : ||' '|| ( Used to make drived attruibutes)
CLAUSES
SELECT Clause (Used to specify the columns (attributes) to retrieve from a table.)
FROM Clause (Specifies the table(s) from which the data is retrieved.)
WHERE Clause( does conditional filtering)
Group By (Groups rows that have the same values in specified columns into summary rows)
Order By(Sorts the query result based on one or more columns in ascending (ASC) or descending (DESC)
order)
Operators:
ARITHMETIC (+.-,*,/,%)
COMPERISION (>,<,=,<=,>=,<>)
RANGE (BETWEEN, AND)
SET MEMBERSHIP (IN)
ASSIGNMENT (=)
LOGICAL(AND, OR NOT)
PATTERN MATCHING (LIKE)
NULL CHECKING ( [IS] NULL)
Constraints
NOT NULL (Ensures that a column cannot have a null value, eg: stdId NOT NULL)
UNIQUE (Ensures that all values in a column are unique , eg: UserId UNIQUE)
PRIMARY KEY(Combines NOT NULL and UNIQUE to uniquely identify each row in a table, eg: stdId
PRIMARY KEY)
FOREIGN KEY(Ensures that a value in one table corresponds to a value in another table's primary key)
DDL
CREATE , ALTER, DROP, TRUNCATE, RENAME
DML
SELECT,INSERT,DELETE,UPDATE
Relational Integrity
The Relational Integrity Rules are a set of constraints in the relational database model that ensure the
accuracy, consistency, and reliability of the data in a database. They are essential for maintaining the
correctness of data relationships. The primary integrity rules are:
1. Entity Integrity Rule
• Definition: Ensures that every table (relation) has a primary key, and the values of the primary
key are unique and not null.
• Purpose: Guarantees that each row in a table can be uniquely identified.
• Example:
In a "Students" table, the StudentID attribute (primary key) must have a unique, non-null value
for every student.
2. Referential Integrity Rule
• Definition: Ensures that a foreign key in one table matches a valid primary key in another table
or is null.
• Purpose: Maintains consistency between related tables by ensuring valid references.
• Example:
If a "Courses" table has a StudentID as a foreign key referencing the StudentID in the "Students"
table, every value in StudentID in "Courses" must exist in the "Students" table or be null.
3. Domain Integrity Rule
• Definition: Ensures that the values in an attribute fall within the defined domain (data type,
range, format).
• Purpose: Validates that the data entered into a table is meaningful and adheres to specified
rules.
• Example:
In a "Employees" table, the Age attribute's domain might be integers between 18 and 65. A
value like 200 or -5 would violate this rule.
4. Key Integrity Rule
• Definition: Ensures that each candidate key in a table has a unique and consistent value across
all rows.
• Purpose: Supports the uniqueness constraint of candidate keys.
Example:
In a "Books" table, ISBN (a candidate key) must have unique values
Database Architecture
The ANSI/SPARC Database Architecture is a framework that describes the structure of database
systems, standardizing how data is accessed, managed, and stored. It is a three-level architecture
proposed by the American National Standards Institute (ANSI) Standards Planning and Requirements
Committee (SPARC). This model ensures data abstraction and independence.
The Three Levels of ANSI/SPARC Architecture
1. External Level (User View):
o The external level defines how individual users or applications view the data.
o Each user sees only the part of the database relevant to them, called a view.
o Provides data security by restricting access to sensitive data.
o Example: A student accessing a database might only see their personal records, while an
administrator sees all students' data.
2. Conceptual Level (Logical View):
o The conceptual level represents the entire database as a whole, including all entities,
attributes, and relationships.
o It describes what data is stored and the relationships between them without worrying
about how the data is physically stored.
o Maintains data integrity and consistency by separating the external and internal levels.
o Example: A "Students" table with all attributes (e.g., ID, Name, Age, Class).
3. Internal Level (Physical View):
o The internal level defines how data is physically stored in the database, including file
structures, indexes, and storage mechanisms.
o Handles data storage, access methods, and optimization.
o Example: Data might be stored in files, indexed, or partitioned across different servers.
Data Independence in ANSI/SPARC Architecture
1. Logical Data Independence:
o Changes at the conceptual level (e.g., adding attributes) do not affect external views.
2. Physical Data Independence:
o Changes at the internal level (e.g., changing storage structures) do not affect the
conceptual schema.
Advantages
• Data Abstraction: Simplifies interaction by hiding implementation details from users.
• Security: Limits user access to specific views of the database.
• Flexibility: Facilitates schema changes without affecting other levels.
• Data Independence: Ensures smooth evolution of the database system
• for all rows.
File Processing Systerm(FPS)
A File Processing System is a system where data is stored and retrieved using individual files. Each file is
usually independent, and applications are designed specifically to handle the data in those files.
Features of File Processing System:
1. Manual Design:
o Data is stored in text files, spreadsheets, or other file formats.
o Files are created and maintained separately for each application.
2. Data Access:
o Access to data requires knowledge of the file structure.
o Applications typically read/write files directly using file-handling code.
3. Organization:
o Files may be stored in sequential, indexed, or hashed formats.
Advantages of File Processing System:
1. Simplicity: Easy to design and understand for small-scale applications.
2. Cost-Effective: No need for specialized software or databases.
3. Custom Solutions: Highly tailored to specific needs of applications.
Limitations of File Processing System:
1. Data Redundancy: Duplicate data across multiple files leads to wastage of storage.
2. Inconsistent Data: Redundancy can cause mismatches between files when updated.
3. Lack of Data Integrity: There's no mechanism to ensure data consistency.
4. Poor Data Security: Files are harder to secure compared to modern databases.
5. Limited Scalability: Becomes inefficient as data volume grows.
6. No Standard Query Language: Requires custom programming for every operation.
Example of File Processing System:
A payroll system where:
• Employee details are stored in one file.
• Salary details are stored in another file.
• Attendance records are stored in a third file. Each file must be manually maintained and linked
by programmers.
DBMS FPS
Entity Relationship Diagram (ERD)
Rules:
1) Identify the active elements of org
2) Identify all the relationship among entities
3) Find the key attributes of entity
4) Identify the other attributes
5) Draw the complete ERD
6) Review and Check ERD