Successfully reported this slideshow.
Your SlideShare is downloading. ×

Ch-11 Relational Databases.pptx

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Introduction to database
Introduction to database
Loading in …3
×

Check these out next

1 of 21 Ad

More Related Content

Similar to Ch-11 Relational Databases.pptx (20)

Advertisement

Ch-11 Relational Databases.pptx

  1. 1. Ch-11 RELATIONAL DATABASES
  2. 2. What’s a Database? ● Organised collection of structured information stored electronically. ● A database typically stores information about one particular business or company. The business then uses that information for decision making. ● The data stored, is independent of programs or applications that use the data. Difference between databases and spreadsheets: 1. Spreadsheets were designed for small number of users. 2. Spreadsheets can store data that is not complex and related to one another. 3. Spreadsheet can store small amount of data. 4. Spreadsheets do not offer data validation. 5. Spreadsheets have limited filtering and searching capabilities.
  3. 3. DBMS Collection of programs which enables users to access the database, manipulate data and help in representation of data. It also helps users to control access to the database by various users. Disadvantages of File based systems: 1. Data redundancy 2. Data inconsistency 3. Unstandardized data 4. Non scalable data 5. Non sharable data 6. Non searchable data 7. Insecure data 8. Does not offer concurrency 9. Does not offer backup or failure recovery 10. Dependency on application programs
  4. 4. What is a Database Model? Set of rules that define how the database organizes and stores the data. It also defines how the users view the data. Types of database models: 1. Hierarchical database model 2. Network database model 3. Relational database model
  5. 5. Relational Database Model ● Data in a relational database model is stored in the form of 2 dimensional tables. ● Within the table, we have rows and columns that are interrelated to each other. ● It is the most widely used database model as accessing of data is very easy. In this model: ● Tables are called as Relations. ● Rows are called as Tuples. ● Columns are called as Attributes.
  6. 6. Components of a Table EMPLOYEE Number Name Salary EMP01 Arun 15000 EMP02 Vishal 20000 EMP03 Nikhil 60000 Fields Records Data items Table Primary key
  7. 7. Relational Model Terms ● Relation - A table in which data is arranged in rows and columns and satisfies all the properties of a relation. ● Domain - Pool of values from which the actual values appearing in a given column are drawn from. ● Tuples - Rows of the relation. ● Attributes - Columns of the relation. ● Degree - Number of attributes in a relation. ● Cardinality - Number of tuples in a relation.
  8. 8. Properties of a Relation 1. In any given column of a table, all items in that column should be of the same kind. 2. For a row, a column cannot have more than one value. 3. All rows of a relation should be distinct from each other. 4. There is no order maintained for rows inside a relation. 5. The columns of a relation should have distinct names. There is no order maintained for columns inside a relation.
  9. 9. Views ● A virtual table that does not really exist in its own. ● It is a table whose contents are derived from one or more base tables. ● There is no file created for storing the contents of the view. ● The contents of the view are determined by the execution of the query. ● Only the definition of the view is stored. ● Everytime a view is referred, its contents are generated dynamically. ● It can be queried, updated, inserted into, deleted from, etc. ● It increases re-usability.You will not have to create complex queries repeatedly. ● Views help in data security. You can use views to show only authorized information to users and hide sensitive data like credit card numbers.
  10. 10. Keys Keys in databases help tell us how rows in a relation are distinct from one another. Types of Keys: ● Primary key - Attributes that can uniquely identify tuples ● Composite Primary key - Group of attributes that can uniquely identify tuples. ● Candidate key - Attributes that can serve as primary keys. ● Alternate key - Candidate key that is not a Primary key ● Foreign key - Non-key attribute whose values are derived from primary key of some other table.
  11. 11. Referential Integrity ● Rules that DBMS uses to ensure relationships between records in related tables are valid. ● These rules also ensure users don’t accidentally delete or change related data. Conditions: 1. Matching field in the primary table should be a primary key. 2. Related fields should have the same data type. 3. Both the related tables should exist in the same database.
  12. 12. History of MySQL ● It was created by MySQL AB, a swedish based company. It was acquired by Sun Microsystems, and the latter was then acquired by Oracle Corp. ● The inventor of MySQL is Michael Widenius. MySQL has been named after his daughter My. The dolphin in the logo is named as ‘Sakila’. ● It is a freely available open source RDBMS. ● A MySQL database can store upto 4 billion tables and each table can store thousands of records. ● It supports a secure environment for storing and maintaining data. ● It is fast, reliable, and scalable alternative compared to other commercial databases.
  13. 13. MySQL ● The objective of any database system is information management. ● MySQL has a client-server architecture in which the server runs on the machine containing the database and clients connect to server over network. ● The server’s operating system can be a Linux or a Windows OS. ● A MySQL server must listen to client requests, access the database, fetch the data and send it back to the client. ● A MySQL client connects to the server and issues queries in a specific format. The client can contact the server programmatically or manually. ● MySQL is also a multi-user database system, where several users can access the database simultaneously.
  14. 14. Key features of MySQL 1. Speed - Very fast, supports clustered servers. 2. Ease of use - Relatively simple to configure and manage. 3. Cost - Free of cost, part of LAMP stack. 4. Query Language Support - Understands SQL 5. Portability - Works on many different platforms. Uses multi-CPU, multi-thread. 6. Data types - Has many data types to support different types of data. 7. Security - Offers privilege and password system. Traffic is encrypted. 8. Scalability - Can handle large databases. 9. Connectivity - Can connect to server using different protocols. 10. Localization - Can provide error messages to clients in many languages. 11. Clients and Tools - Has several client and utility tools.
  15. 15. SQL ● Language that allows you to create and operate on relational databases. ● Allows users to learn one set of commands and use it to create, retrieve, alter and transfer information regardless of the system they are working on. ● Has proved to be the standard language that is recognised by all the RDBMS. ● The original version was developed at IBM San Jose Research Lab in 1970s and was originally called as Sequel. ● In 1986, ANSI published the SQL standard and updated it over the years in 1992, 2003 and 2008.
  16. 16. Key features of SQL 1. DDL - Provides commands for defining schemas 2. Interactive DML - Provides commands for altering data 3. Embedded DML - Can be used inside programming languages like C, C++ 4. View definitions - Provides commands for creating views 5. Authorization - Includes commands for specifying access rights to relations 6. Integrity - Provides integrity checking. 7. Transaction Control - Provides commands for controlling transactions.
  17. 17. Data Definition Language ● Identifies the type of data such as data item, record, database file, etc. ● Gives unique name to each data item, record, database file, etc. ● Specifies proper data types for columns ● Specifies how records are related. ● Defines the type of encoding in data items. ● Defines the length of data items. ● Specifies the domain of data items. ● Specifies means of error checking in data. ● Specifies privacy locks for unauthorized reading or modification ● Does not specify addressing, indexing or searching techniques.
  18. 18. Classification of SQL statements 1. DDL commands 2. DML commands 3. TCL commands 4. Session control commands 5. System control commands
  19. 19. DDL commands Performs tasks related to schema objects such as: ● Creating, altering and dropping schemas ○ CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX, ALTER INDEX, DROP INDEX, RENAME TABLE, TRUNCATE ● Granting and revoking privileges ○ GRANT privilege ON object TO user ○ REVOKE privilege ON object FROM user ● Maintenance commands ○ ANALYZE TABLE, CHECK TABLE, REPAIR TABLE, RESTORE TABLE
  20. 20. DML commands Performs tasks related to stored data sitting inside the schema objects such as: ● retrieval of data ● insertion of new data ● deletion of data ● modification of data Commands under DML: ● SELECT ● INSERT ● DELETE ● UPDATE
  21. 21. TCL commands Performs tasks related to managing and controlling transactions. These commands manage changes made by DML commands. Commands under TCL: ● COMMIT ● ROLLBACK ● SAVEPOINT ● SET TRANSACTION

×