Database Fundamentals Flashcards
(121 cards)
What is a database?
- organised collection of data, typically stored in electronic format
- allows you to input, organise and retrieve data quickly
What is a query?
-inquiry into the DB that returns information back
What is an index?
- data structure that improves the speed of the data retrieval operations on a DB table
- have disadvantage in that they need to be created and updated which requires processing resources and takes up disk space
What is a database server?
- DB’s often stored on there so they can be accessed by multiple users and provide a high level of performance
- DB servers do not house any form of application and instead are optimised to serve only the purpose of the DB itself using advanced hardware that can handle the high processing needs
- Usually racks
What is Microsoft SQL server?
A DB server. Has 3 types of files to store DB’s;
- primary data files have an .mdf extension and are the first files created in a DB. Contain user-defined objects, such as tables and views as well as system tables that SQL server requires for keeping track of the DB
- if DB becomes too large and you run out of room on first hard disk you can create secondary data files which have a .ndf extension, on seperate hard disks
- Transaction log file use a .ldf extension and don’t contain objects
What is a DBMS?
-collection of programs that enables you to enter, organise and select data in a database
What is a flat file DB?
- 2D tables consisting of rows and columns
- each column is a field and each row is a record
- access, performance and queries are quick on a flat file DB
- .txt file
What is a Hierarchical DB?
-tree structure, each parent table can have multiple children but the children can only have one parent
What is a relational DB?
- similar to hierarchical in that data is stored in tables and any new info is added into it without need for reorganisation
- can have multiple parents unlike hierarchical
- each column corresponds to an attribute and each row to a record
What are the fundamental characteristics of a DB?
- designed to store billions of rows of data
- limited to the computers available hard disk space
- optimised to use all the computers available memory to improve performance
What is a calculated value?
-value that results from the performance of some sort of calculation or formula on a specified input value
How are DB objects divided?
-into storage and programmability
What are constraints?
-limitations or rules placed on a field or column to ensure that data that is considered invalid is not entered
Some types of constraints available?
- unique = allows DB admin to ID which column should not contain duplicates
- check = allows admin to limit types of data user can insert into DB
- default = used to insert default value into a column if no other value specified
- not null = ensures data is entered into cell
- primary key = uniquely ID’s each record in a DB
- foreign key = in one table points to primary key in another table (can contain null values)
What is self reference?
-where a foreign key constraint references columns in the same table
What is SSMS?
- SQL Sever Management System
- primary tool to manage a server and its DB using a GUI
- can be used to view and optimise DB performance, as well as to create and modify DB’s, tables and indexes
- includes query analyser which provides GUI based interface to write and execute queries.
What are the 3 things SSMS query analyser supports?
- Xquery = query and functional programming language that is designed to query collection of XML data
- SQLCMD =command line app that comes with SQL server and exposes the management features of it. Allows SQL queries to be written and executed from the command prompt. Can also create SQL script files (.sql) to run a set of SQL statements as a script
- Transact-SQL = primary means of programming and managing SQL server. When you use SSMS to perform an action or task you are using this
What is data manipulation language (Dml)
- the language element that allows you to use the core statements SELECT, INSERT, UPDATE, DELETE and MERGE to manipulate data in any SQL server tables
- select = retrieves rows from DB and enables the selection of one or many rows or columns from one or many tables
- insert = adds one or more new rows to a table or a view
- update = change existing data in one or more columns in a table or view
- delete = removes rows from a table or view
- merge =performs insert, update, or delete operations on a target table based on the results of a join with a source table
What is special about DML statements?
- they either succeed or fail
- if you tried to insert 10,000 records into a table but violated one of the primary key the entire 10,000 rows of records would roll back and not one record would be inserted into the table
What is Data definition language?
- subset of the Transact SQL language
- deals with creating DB objects like tables, constraints and stored procedures
- The interface used to create these underlying DDL statements is the SSMS UI
What are the limitations of the SSMS when using DDL statements?
- allows you to visually design DDL statements and a DDL script statement task can be completed through its UI
- but not all the operations you may wish to use can be accomplished through this interface
- have to be familiar with the statements themselves
- most DDL statements can be executed through SSMS but using the statements themselves gives you more power, flexibility and control
What are some key DDL statements?
- USE = changes the DB context, when performing commands you will have to enter the USE command to select the DB first
- CREATE = creates a SQL server DB object
- ALTER = change an existing object
- DROP = removes an object from the DB, error will be raised if other objects are dependent on the object being removed
- TRUNCATE = removes rows from a table and frees the space used by those rows, better for larger DB’s
- DELETE = remove rows from a tables but does not free the space used by those rows removed, better for smaller DB’s
What are system tables?
- keep track of DB
- when you want to query system views to verify where the object(s) you wish to drop are in the DB tables, you need to know what tables are the most useful
- system views belong to the sys schema
- some of those tables include; sys.Tables, sys.Columns, sys.Database, sys.Constraints, sys.Views and sys.Objects
What is a data type?
An attribute that specifies the type of data an object can hold, as well as how many bytes each type take sup