Sei sulla pagina 1di 6

Unit II

What is RDBMS?
− RDBMS stands for Relational Database Management System.
− RDBMS is the basis for SQL, and for all modern database systems like MS SQL Server, IBM
DB2, Oracle, MySQL, and Microsoft Access.
− A Relational database management system (RDBMS) is a database management system
(DBMS) that is based on the relational model as introduced by E. F. Codd.
What is a table?
− The data in an RDBMS is stored in database objects which are called as tables.
− This table is basically a collection of related data entries and it consists of numerous columns and
rows.
− Remember, a table is the most common and simplest form of data storage in a relational database.
− The following program is an example of a CUSTOMERS table −
+----+----------+-----+-----------+----------+
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 |
| 4 | Chaitali | 25 | Mumbai | 6500.00 |
| 5 | Hardik | 27 | Bhopal | 8500.00 |
| 6 | Komal | 22 | MP | 4500.00 |
| 7 | Muffy | 24 | Indore | 10000.00 |
+----+----------+-----+-----------+----------+
What is a field?
− Every table is broken up into smaller entities called fields.
− The fields in the CUSTOMERS table consist of ID, NAME, AGE, ADDRESS and SALARY.
− A field is a column in a table that is designed to maintain specific information about every record
in the table.
What is a Record or a Row?
− A record is also called as a row of data is each individual entry that exists in a table.
− For example, there are 7 records in the above CUSTOMERS table.
− Following is a single row of data or record in the CUSTOMERS table −
+----+----------+-----+-----------+----------+
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |
+----+----------+-----+-----------+----------+

− A record is a horizontal entity in a table.


What is a column?
− A column is a vertical entity in a table that contains all information associated with a specific field in
a table.
− For example, a column in the CUSTOMERS table is ADDRESS, which represents location
description and would be as shown below −
+-----------+
| ADDRESS |
+-----------+
| Ahmedabad |
| Delhi |
| Kota |
| Mumbai |
| Bhopal |
| MP |
| Indore
Advantages of Relational Database Management Systems
1. Single Data Locations: A primary benefit of using an RBDMS is that data is only stored in one
location. A customer's name and address can be stored in one table, accessible to sales, customer
service, accounting, shipping and any other department that needs it, rather than each department
having its own record of the same information. Once the information is added, changed or deleted by
one person, people in other departments don't need to change it too.
2. Queries: RDBMS supports complex queries so that information across different tables can be
retrieved all at once. For example, you could quickly find out which of your products are most
popular in different cities, or find out what the average customer spends on your products based on
gender, age or which state they live in.
3. Security: RDBMS offers varied security for different tables. Tables can be made accessible only to
those who need specific information. For example, customer service and the shipping department
could have access to client names and addresses, while payment information and outstanding
accounts could be limited to the accounting department.
4. Ease of Use: A fourth benefit of RDBMS is that it is generally easy to use and understand, because
information is stored in tables, organized in rows and columns, much the same as a spreadsheet.
Disadvantages of Relational Model Databases
1. Cost: Setting up and maintaining an RDBMS can be an expensive undertaking, often beyond the
budget of a small business. To begin with, you need to purchase the software and, in many cases,
hire a professional database administrator or programmer experienced in Structured Query
Language, or SQL, to set it up. Once the database is set up, you then need to enter information into
the database, or import it from existing records, which can be time consuming and, thus, expensive.
If your database is going to contain sensitive information, like credit card numbers or Social Security
numbers, you will need to ensure that the information is secured against unauthorized users, which
adds another layer of cost to the implementation.
2. Limitations in Structure: Many relational database systems impose limits on the lengths of data
fields. If you enter more information into a field than it can accommodate, the information will be
lost.
3. Isolated Information: Because relational databases can use a large number of tables, there is always
the risk that some information may be lost or forgotten, particularly when it is being transferred from
one system to another. This is usually more of a problem for large organizations, particularly when
they are using different database systems.
Unit III What are Keys?
− A key is an attribute or set of an attribute which helps you to identify a row (tuple) in a relation
(table).
− They allow you to find the relation between two tables.
− Keys help you uniquely identify a row in a table by a combination of one or more columns in that
table.
Why we need a Key?
Here, are reasons for using Keys in the system.
• Keys help you to identify any row of data in a table. In a real-world application, a table could contain
thousands of records.
• Moreover, the records could be duplicated. Keys ensure that you can uniquely identify a table record
despite these challenges.
• Allows you to establish a relationship between and identify the relation between tables
• Help you to enforce identity and integrity in the relationship.
What is the Super key?
• A superkey is a group of single or multiple keys which identifies rows in a table.
• A Super key may have additional attributes that are not needed for unique identification.
Example:

What is a Primary Key?


• A column or group of columns in a table which helps us to uniquely identify every row in that table
is called a primary key.
• This DBMS can't be a duplicate.
• The same value can't appear more than once in the table.
Rules for defining Primary key:
• Two rows can't have the same primary key value
• It must for every row to have a primary key value.
• The primary key field cannot be null.
• The value in a primary key column can never be modified or updated if any foreign key refers to that
primary key.
Example:
In the following example, <code>StudID</code> is a Primary Key.

What is a Candidate Key?


• A super key with no repeated attribute is called candidate key.
• The Primary key should be selected from the candidate keys.
• Every table must have at least a single candidate key.
Properties of Candidate key:
• It must contain unique values
• Candidate key may have multiple attributes
• Must not contain null values
• It should contain minimum fields to ensure uniqueness
• Uniquely identify each record in a table
Example:
− In the given table Stud ID, Roll No, and email are candidate keys which help us to uniquely identify
the student record in the table.
What is the Foreign key?
• A foreign key is a column which is added to create a relationship with another table.
• Foreign keys help us to maintain data integrity and also allows navigation between two different
instances of an entity.
• Every relationship in the model needs to be supported by a foreign key.
Example:

− In this example, we have two table, teach and department in a school. However, there is no way to
see which search work in which department.
− In this table, adding the foreign key in Deptcode to the Teacher name, we can create a relationship
between the two tables.
What is the Composite key?
• A composite key is a combination of two or more columns in a table that can be used to uniquely
identify each row in the table when the columns are combined uniqueness is guaranteed, but when it
taken individually it does not guarantee uniqueness.
• Sometimes more than one attributes are needed to uniquely identify an entity.
• A primary key that is made by the combination of more than one attribute is known as a composite
key.
• A key which has multiple attributes to uniquely identify rows in a table is called a composite key.
• The difference between compound and the composite key is that any part of the compound key can
be a foreign key, but the composite key may or maybe not a part of the foreign key.
• A primary key having two or more attributes is called composite key. It is a combination of two or
more columns.
• An example can be:

Here our composite key is OrderID and ProductID:

− Above, our composite keys are StudentID and StudentEnrollNo. The table has two attributes as
primary key.
− Therefore, the Primary Key consisting of two or more attribute is called Composite Key.
Difference between Primary and Candidate Key:

Difference between Super Key and Candidate Key:

Potrebbero piacerti anche