Database Basics

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

In database terminology, what is the primary role of a database administrator?

  • Securing the database system against unauthorized access and ensuring user access. (correct)
  • Interacting with database systems on behalf of business users.
  • Determining the format of each data element and the overall database structure.
  • Developing computer programs that utilize databases.

What characteristic defines 'analog' data in the context of database systems?

  • Encoded as zeros and ones on magnetic media.
  • Encoded as continuous variations on physical media. (correct)
  • Encoded as zeros and ones on electronic media.
  • Stored on paper or clay tablets.

Which component of a database system translates query processor instructions into low-level file-system commands?

  • Database Application
  • Transaction Manager
  • Storage Manager (correct)
  • Query Processor

What is the key role of a transaction manager in a database system?

<p>To ensure that all transactions are executed completely and properly. (A)</p> Signup and view all the answers

Which of the following best describes the role of a database designer?

<p>To determine the format of data elements and the overall database structure, balancing priorities. (C)</p> Signup and view all the answers

What is the primary function of a 'query language' in the context of databases?

<p>To write database queries for inserting, retrieving, updating, or deleting data. (C)</p> Signup and view all the answers

What does the acronym 'CRUD' stand for in the context of database operations?

<p>Create, Read, Update, Delete (D)</p> Signup and view all the answers

What is the main purpose of the analysis phase in database design?

<p>To specify database requirements without regard to a specific database system. (C)</p> Signup and view all the answers

Which database component is responsible for ensuring that data adheres to structural and business rules?

<p>Rules Engine (A)</p> Signup and view all the answers

What term describes data about the database structure, such as column names and the number of rows in each table?

<p>Metadata (D)</p> Signup and view all the answers

In database systems, what is the purpose of a 'log'?

<p>To record all inserts, updates, and deletes processed by the database. (C)</p> Signup and view all the answers

What is the role of the 'catalog' or 'data dictionary' in a database system?

<p>It contains a directory of tables, columns, indexes, and database objects. (A)</p> Signup and view all the answers

Which type of database is characterized by storing data in tables, columns, and rows, similar to a spreadsheet?

<p>Relational Database (B)</p> Signup and view all the answers

What does SQL stand for, and what is its primary function?

<p>Structured Query Language; used for database communication. (A)</p> Signup and view all the answers

In the context of database systems, what is 'big data' typically characterized by?

<p>Massive volumes of online data, often poorly structured or missing information. (D)</p> Signup and view all the answers

What is the key characteristic of 'NoSQL' databases?

<p>They are non-relational and often used for big data. (D)</p> Signup and view all the answers

Which term refers to software that allows anyone to inspect, copy, and modify the source code without licensing fees?

<p>Open Source (C)</p> Signup and view all the answers

Which of the following best describes a 'query' in the context of a database?

<p>A command for a database to insert, retrieve, update, or delete data. (D)</p> Signup and view all the answers

What is the purpose of the SQL CREATE TABLE statement?

<p>To create a new table by specifying the table and column names. (B)</p> Signup and view all the answers

What does the term 'data type' refer to in the context of database columns?

<p>The format of column values, such as numeric, textual, or complex. (A)</p> Signup and view all the answers

In ER diagrams, what do rectangles typically represent?

<p>Entities (B)</p> Signup and view all the answers

What does the 'logical design' phase involve regarding database requirements?

<p>Converting entities, relationships, and attributes into tables, keys, and columns. (B)</p> Signup and view all the answers

What is the term for the logical design of a database, as specified in SQL and depicted in a table diagram?

<p>Database Schema (A)</p> Signup and view all the answers

What is the primary focus of the 'physical design' phase in database development?

<p>Adding indexes and specifying how tables are organized on storage media. (D)</p> Signup and view all the answers

Which principle states that the physical design should not affect the query results?

<p>Data Independence (B)</p> Signup and view all the answers

If database designers modify indexes or row order, what is a likely outcome?

<p>Applications may run faster or slower, but generate the same results. (C)</p> Signup and view all the answers

What is an Application Programming Interface (API) in the context of databases primarily used for?

<p>Simplifying the use of SQL with a general-purpose language. (B)</p> Signup and view all the answers

Which of the following components is part of the default MySQL Server download and allows developers to connect to the database server to execute SQL statements?

<p>MySQL Command-Line Client (A)</p> Signup and view all the answers

In the context of database systems, what is a 'database model'?

<p>A conceptual framework for how data is organized within the database system. (A)</p> Signup and view all the answers

Which term describes an unordered collection of unique elements enclosed in braces?

<p>Set (C)</p> Signup and view all the answers

Which term refers to an ordered collection of elements enclosed in parentheses?

<p>Tuple (B)</p> Signup and view all the answers

What is another term for a column in a table?

<p>Field (A)</p> Signup and view all the answers

What is Data Definition Language (DDL) used for?

<p>Defining the structure of the database, including creating, altering, and dropping database objects. (D)</p> Signup and view all the answers

Which SQL command is used to select a default database for subsequent SQL statements?

<p>USE DATABASE (D)</p> Signup and view all the answers

In SQL, which statement is used to delete all rows from a table while keeping the table structure intact?

<p>TRUNCATE TABLE (A)</p> Signup and view all the answers

What is the purpose of a 'PRIMARY KEY' in a database table?

<p>To uniquely identify each row in the table. (B)</p> Signup and view all the answers

What type of key consists of multiple columns to identify a row?

<p>Composite Key (B)</p> Signup and view all the answers

In database design, what is the function of a 'FOREIGN KEY'?

<p>It refers to a primary key in another table. (B)</p> Signup and view all the answers

What does 'Referential Integrity' ensure regarding foreign key values?

<p>Foreign key values must either be NULL or match a value in the referenced primary key. (B)</p> Signup and view all the answers

What happens to foreign keys when ON DELETE CASCADE is enabled, and a record in the parent table is removed?

<p>Rows with matching foreign keys in the child table are automatically removed. (C)</p> Signup and view all the answers

Flashcards

Data

Numeric, textual, visual, or audio information that describes real-world systems.

Analog data

Data encoded as continuous variations on physical media.

Digital data

Data encoded as zeros and ones on electronic and magnetic media.

Database

A structured collection of data, typically stored on computers.

Signup and view all the flashcards

DBMS

Software that reads and writes data in a database.

Signup and view all the flashcards

Query language

A specialized programming language for database systems.

Signup and view all the flashcards

Database application

Software that helps business users interact with database systems.

Signup and view all the flashcards

Database administrator

Responsible for securing the database system against unauthorized users.

Signup and view all the flashcards

Database designer

Determines the format of data and the overall database structure.

Signup and view all the flashcards

Database programmer

Develops computer programs that utilize a database.

Signup and view all the flashcards

Database user

A consumer of data in a database.

Signup and view all the flashcards

Authorization

Limited access to specific parts of a database.

Signup and view all the flashcards

Transaction

Queries that must be fully completed or fully rejected.

Signup and view all the flashcards

Database architecture

Describes Internal components and their relationships within database system

Signup and view all the flashcards

Query processor

Interprets queries and returns results.

Signup and view all the flashcards

Query optimization

Query processor ensuring efficient instruction execution.

Signup and view all the flashcards

Storage manager

Translates processor instructions into file-system commands.

Signup and view all the flashcards

Indexes

Used by the storage manager to locate data quickly.

Signup and view all the flashcards

Transaction manager

Ensures transactions are properly executed.

Signup and view all the flashcards

Metadata

Data about data, such as column names.

Signup and view all the flashcards

Log

A file containing a complete record of database changes.

Signup and view all the flashcards

Catalog / data dictionary

A directory of tables, columns, and indexes.

Signup and view all the flashcards

Relational database

Stores data in tables, columns, and rows.

Signup and view all the flashcards

SQL

Standard query language for relational databases.

Signup and view all the flashcards

Big data

Massive volumes of online data from the 1990s.

Signup and view all the flashcards

NoSQL

Non-relational, optimized for big data.

Signup and view all the flashcards

Open source

Software that anyone can inspect, copy, and modify.

Signup and view all the flashcards

Query

A command that inserts, retrieves, updates, or deletes data.

Signup and view all the flashcards

Query language

Programming language for writing database queries.

Signup and view all the flashcards

CRUD

Operations: Create, Read, Update, Delete.

Signup and view all the flashcards

Statement

An SQL database command.

Signup and view all the flashcards

UPDATE

Statement modifying data in a table.

Signup and view all the flashcards

DELETE

Statement deleting rows from a table.

Signup and view all the flashcards

CREATE TABLE

Creates a new table by specifying the table and column names.

Signup and view all the flashcards

Data type

Indicates the format of column values.

Signup and view all the flashcards

Database design

Specification of database objects.

Signup and view all the flashcards

Analysis

Specifies database requirements without regard to a specific system.

Signup and view all the flashcards

ER diagrams

High-level representation with entities, relationships, and attributes.

Signup and view all the flashcards

Logical design

Implementing database requirements in a specific system.

Signup and view all the flashcards

Physical design

Adds indexes and specifies table organization.

Signup and view all the flashcards

Study Notes

Database Basics

  • Data is information describing real-world systems, represented numerically, textually, visually, or as audio.
  • Analog data is encoded as continuous variations on physical media
  • Digital data: encoded as zeros and ones on electronic and magnetic media.
  • A database: structured data collection in a structured format, typically stored on computers
  • A database system/database management system (DBMS): software that reads and writes data in a database, ensures data is secure, consistent, and available

Database System Components

  • Query language is a specialized programming language for database systems.
  • Database application: software to interact with database systems.
  • Database administrator: secures the database system, enforces user access procedures.
  • Database designer: determines the format of data and database structure, balances storage, response time and rules
  • Database programmer: develops computer programs that use a database.
  • Database user: a consumer of data in a database who requests, updates, or uses data via applications or queries.

Database Systems: Key Concepts

  • Authorization: limits user access to specific parts of a database
  • Rules: ensure data consistency with structural and business rules.
  • Transaction: a group of queries that must be fully completed or rejected to maintain data integrity.
  • Architecture: defines the internal components and relationships within a database system.

Query Processing

  • Query processor: interprets queries, plans modifications/retrieval, and returns results
  • Query optimization: ensures efficient execution of instructions on data.
  • Storage manager: translates query instructions into low-level file-system commands.
  • Indexes: used by the storage manager for quick data location.
  • Transaction manager: ensures proper execution of transactions.
  • Metadata: data about the database (e.g., column names, row counts).
  • Log: a file recording all database inserts, updates, and deletes.
  • Catalog/data dictionary: directory of tables, columns, indexes, and other database objects.

Database Types and Languages

  • Relational database: stores data in tables with rows and columns, supports SQL.
  • SQL: Structured Query Language for data manipulation and system administration.
  • Big data: massive volumes of online data, often unstructured, generated since the 1990s.
  • NoSQL: non-relational systems optimized for big data.
  • MongoDB: big data, open source, NoSQL database.
  • Open source software: allows inspection, copying, and modification without licensing fees.

Query Languages

  • Query: a database command to insert, retrieve, update, or delete data.
  • Query language: programming language for writing database queries.
  • CRUD operations: Create, Read, Update, and Delete the four common queries
  • SQL: the standard query language for relational database systems.
  • Statement: an SQL command (e.g., INSERT, SELECT, UPDATE, DELETE).

SQL Operations

  • INSERT: adds rows into a table
    INSERT INTO table_name (column_name1, column_name2, ...) VALUES (DEFAULT, 'bob', 30, 150);
    
  • SELECT: retrieves data from a table
    SELECT column1, column2, ... FROM table_name; -- return all data from those columns.
    
  • UPDATE: modifies data in a table
    UPDATE table_name SET column_name = 2 WHERE column_id = 3;
    
  • DELETE: deletes rows from a table
    DELETE FROM table_name; -- all rows deleted!
    DELETE FROM table_name WHERE column_name = 'value'; -- delete row
    
  • CREATE TABLE: creates a new table by specifying the table and column names
    CREATE TABLE Customers (
        customerId INT NOT NULL UNIQUE,
        first_name VARCHAR(255) NOT NULL,
        age INT CHECK(age > 18)
        driverid INT NOT NULL,
        PRIMARY KEY (customerId),
        FOREIGN KEY (LOCAL_COLUMN_NAME) REFERENCES TABLE_NAME (COLUMN_NAME),
    );
    
  • Data type specifies format of column values, can be numeric, textual, or complex.

Database Design Phases

  • Database design specifies tables, columns, data types, and indexes.
  • Analysis phase defines database requirements independently of specific systems, and uses entities, relationships, and attributes.
  • Logical design implements database requirements in a specific database system, and converts entities, relationships, and attributes into tables, keys, and columns called a database schema
  • Keys identify individual rows in tables using SQL with CREATE TABLE.
  • The physical design phase adds indexes and specifies storage media organization to affect query processing speed, while preserving data independence

Additional Concepts

  • Data independence: physical design does not affect query results
  • API: application programming interface simplifies SQL use with general-purpose languages.
  • MySQL: Oracle-sponsored relational database system.
  • MySQL Community/Server: a free edition.
  • MySQL Enterprise: paid version with commercial database management.
  • Root account: administrative account with full MySQL control.
  • MySQL Command-Line Client: text interface for database administration and SQL execution.
  • Workbench: allows SQL command execution using an editor.

Relational Model

  • Relational Model: with Data structures, integrity and manipulation constraints, and operations
  • Relational databases store data in Data type specific tables with primary and foreign keyed columns
  • Data structures form the backbone of efficient and organized information storage.
  • Indexes are used to help retrive data effieicntly
  • Relational Model was was first proposed in 1970 by Edgar Codd of IBM and first implemented in 1980s
  • Standard quer language is SQL for manipulating data
  • Sets have unordered elements, e.g. {a, b, c} is equal to {c, b, a}
  • Tuples have ordered elements, e.g. (a, b, c) is not equal to (c, b, a) and are put in parenthesis

Relational Model Tables

  • Table also called File,Relation
  • Column also called Field,Attribute
  • row also called Record, Tuple
  • Relational data types are are named set of values, from which column values are drawn.
  • Operations are collectively knownRelational algebra, SQL language is built onto the fundamentals.
  • Relational rules ensures data is valid, as logical constraints on data value

SQL Components and Literals

  • Structured Query Language (SQL) is a high-level computer language for storing, manipulating, and retrieving data to use with relational and non relational datasets
  • Common SQL Literals are Strings, Numbers, Binary
  • Strings use or
  • Numbers use integers and decimals
  • Binary uses x’ofa2’

SQL Grammar

  • Keyword are special meaning words eg. SELECT, FROM, WHERE
  • Identifiers are the referenced database items eg City, Name, Population
  • Statementsare 1 or more clauses (command(s)
  • Clause group up keywords into conditional groups SELECT, FROM, and WHERE
  • Data Definitio, language (DDL) are used to define the structure such as CREATE, ALTER, DROP
  • Data manipuilation (DML) are for working on (manipulation) datastored eg,. INSERT, UPDATE, DELETE
  • Data query Languge (DQL) is a method to retrieve data suchas SELECT Data control Languge (DCL) controls user access with GRANT, REVOKE
  • Data tx Languge (DTL) manages db tnx using **SAVEPOINT, ROLLBACK, COM

Instance and Management

  • Database System Instance is when you have access to a database, (instance)
  • Instance can be for local, or cloud
  • Command CREATE DATABASE database_name Creates a named database
  • Command DROP DATABASE database_name drop a database and all tables inside/related components table
  • Command SHOW DATABASES List out all available databases
  • Command SHOW TABLES Show all tables in database
  • Command SHOW COLUMNS FROM table_name List out all availablecolumns/attributes of table
  • CommandSHOW CREATE TABLE table_name List out the DDL that was required to create a table

Tables

  • Tables have a name, sequence of columns (tuple), and a list of rows
  • Columns and rows have individual datatypes
  • Exact on value for each cell (attributes/value)
  • No duplicated columns (same or diff table)
  • No duplicated rows (same columns of a new row)
  • No row order (how physical organized not important
  • The above concept is refered to as data independence from performance
  • Data definition Languge (DDL) commandCREATE TABLE creates a new table
  • Data definition Languge (DDL) command DROP TABLE TableName;Delete's the table
  • DDL command ALTER TABLE TableName Modifes the tables, such as columns/attributes and their definitions

SQL Data Types

  • Data types used to draw coul values from an assigned value
  • INTorINTEGER`` Integer with (+/-) numbers VARCHAR(N) strings with N chars
  • *CHAR(N)fixed valued char string with N` chars
  • DATE stored as mm/dd/yyyy
  • DECIMAL(N, D) Total value N with D decimal places

Data Operators and Selecting Rows

  • Expressions use operators and operands , and parentheses of different datatypes
  • Order of operations(PEMDAS, BODMAS)
  • SELECT statement will SELECT columns and FROM tables
  • WHERE statement will SELECT * FROM when * meets conditions and is TRUE,orNULL
  • Can use LIMIT to define how many values returned at max

Null Values

  • Have NULL as representation, where its special cased depending
  • NOT NULL constraint prevents NULL data, and will reject values
  • to check if there is a value or its IS NULL

Insert Update and Delete

  • MySQL
    • INSERT statement adds rows
    • INSERT clause names table and column
    • VALUES values
  • Keywords from UPDATE
    • Update table
    • Can use optional where clause Keywords from DELETE
    • Delete from table
    • Optional where value
  • TRUNCATE keywords, will`Delete allrows but keep tables
  • MERGE: will select from one and insert somewhere else

Primary Keys

  • Composite primary key: uses multi-columns
  • Use minimal to remove redundency
  • FOREIGN KEY column for referencing
  • ON UPDATE,ON DELETE statements

constraints

  • Table constraints (not null) use separate cause CREATE TABLE, to govern multi- and column

    Operators

  • Used with where clauses
    IN() , when comparing one or the list of values
    BETWEEN, for all values

  • Note that column LIKE and BINARY() operators function differently, with case sensitivity
    DISTINCT statement, used to return only unique values ORDER BY statements, order DESC keyword can used to reverse

function arguments

ABS() returns value from negative with number LOWER lower case TRIM () removes whitespace HOUR, MINUTE, SECOND

Aggregate Functions

  • These functions is from set rows and returns summar value COUNT() MIN() MAX() SUM() AVG ()
  • Can also use GROUP BY and filter, HAVING condition

Joins

  • SELECT column name `AS`` (use as), used to simplify, query
  • join from table X and Y table, to output, where X AND Y column Z meet/match criteria
  • Join methods
    • INNER only matching left and right table
    • FuLL: all
    • ON:specifies join

outer join

  • When joined select is unmatched row including left, right
  • SELECT``X.name, Y.name FROM X, Y WHERE `X.id=Y.id, UNION

Equi joins, self joins and cross joins

  • equi jjoin comparess columns or multiple table columns with = operator,A.x=``B.y
  • non-equi is different with < and >
  • for self joins it to itself SELECT x.name B.manager.. FROM employee X join employee Y ...

Sub queries

  • subquery = nested or inner query Ex using IN
SELECT * FROM TABLE1
WHERE percentage IN (SELECT percentage
FROM TABLE1
WHERE columnname = ‘ABW’);

Views

  • Views = virtual tables that will get created on runtime
CREATE VIEW NAME AS  SELECT DEPT FROM EMP

  • Materialize views are data that are pre computed and stored separately And use in select statements
  • The difference to view is that those compute and return when called The materialzied just gets read

##Replicational ALgebra

  • Consists of many small operation to create something complex
  • SELECT - choose row base don conditin
  • PROJECT - chooses base on columns
  • Prod uct operation combine tables
  • JOIN: combine select row and filter
  • Set operation used for union, intersect, difference
    • Similar as venn diagrams

ER ALgrebra Model

  • Database design starts with what the design as specified
  • The relational algebra is ER model
  • Entity = noun/things relationship - verb (join) Attributes = describes entities

Other Modeling Details

  • Each entity has a relationship
  • Entity relationship diagram
  • Cardinality is attribute relationship, And has min and max values

-Super type and sub type

  • Use single or plural
  • ERDs often use a min or max values

Other Database Design

  • To select keys Stable should not change value simple easy store meaninglessNo descriptive Select for type based on table and weak/composite constraints

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Database Management Systems Quiz
10 questions

Database Management Systems Quiz

HonestTropicalIsland4063 avatar
HonestTropicalIsland4063
Database Management Systems (DBMS)
17 questions
Data Management and Database Systems
44 questions
Use Quizgecko on...
Browser
Browser