Publicité
Publicité

Contenu connexe

Publicité

E-R diagram & SQL

  1. Welcome to our Presentation Topic: E-R diagram & SQL Presented by: The roll of 20, 22, 23, 30 & 38 Batch: E-56 Dhaka International University (DIU)
  2. Entity Relationship Diagram (ERD) An Entity Relationship Diagram (ERD) is a snapshot of data structures. An Entity Relationship Diagram shows entities (tables) in a database and relationships between tables within that database. For a good database design it is essential to have an Entity Relationship Diagram. There are three basic elements in ER-Diagrams:  Entities are the "things" for which we want to store information. An entity is a person, place, thing or event.  Attributes are the data we want to collect for an entity.  Relationships describe the relations between the entities.
  3. Symbol used in E-R diagram  Rectangles: Represent entity sets.  Diamonds: Represent relationship sets.  Lines: Link attributes to entity sets and entity sets to relationship sets.  Ellipses: Represent attributes.  Double ellipses: Represent multi-valued attributes.  Dashed ellipses: Denote derived attributes.  Underline: Indicates primary key attributes. (Describe later)
  4. E-R Diagram With Composite, Multi-valued and Derived Attributes Mapping Cardinality & Constraints Mapping Cardinality:  Express the number of entities to which another entity can be associated via a relationship set.  Most useful in describing binary relationship sets. For a binary relationship set the mapping cardinality must be one of the following types:  One to many  One to one  Many to one  Many to many Cardinality & Constraints: We express cardinality constraints by drawing either a directed line (→), signifying “one,” or an undirected line (—), signifying “many,” between the relationship set and the entity set.
  5.  One-to-One  A customer is associated with at most one loan via the relationship borrower  A loan is associated with at most one customer via borrower  One-to- Many  In the one-to-many relationship a loan is associated with at most one customer via borrower, a customer is associated with several (including 0) loans via borrower
  6.  Many-to-One  In a many-to-one relationship a loan is associated with several (including 0) customers via borrower, a customer is associated with at most one loan via borrower  Many-to- Many  A customer is associated with several (possibly 0) loans via borrower  A loan is associated with several (possibly 0) customers via borrower
  7. Alternative Notation for Cardinality Limits Participation of an Entity Set in a Relationship Set Keys Primary Key – A primary is a column or set of columns in a table that uniquely identifies tuples (rows) in that table. Super Key – A super key is a set of one of more columns (attributes) to uniquely identify rows in a table. Candidate Key – A super key with no redundant attribute is known as candidate key. Foreign Key – Foreign keys are the columns of a table that points to the primary key of another table. They act as a cross-reference between tables.
  8. Structured Query Language(SQL) What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database. According to ANSI (American National Standards Institute), it is the standard language for relational database management systems. SQL statements are used to perform tasks such as update data on a database, or retrieve data from a database. Some common relational database management systems that use SQL are:  Oracle  Microsoft SQL Server  MySQL, etc. (We describe MySQL here.) Although most database systems use SQL, most of them also have their own additional proprietary extensions that are usually only used on their system. However, the standard SQL commands such as "Select", "Insert", "Update", "Delete", "Create", and "Drop" can be used to
  9. MySQL MySQL: MySQL is a fast, easy-to-use RDBMS being used for many small and big businesses. MySQL is becoming so popular because of many good reasons :−  MySQL is released under an open-source license. So we have nothing to pay to use it.  MySQL is a very powerful program in its own right. It handles a large subset of the functionality of the most expensive and powerful database packages.  MySQL uses a standard form of the well-known SQL data language.  MySQL works on many operating systems and with many languages including PHP, PERL, C, C++, JAVA, etc.  MySQL works very quickly and works well even with large data sets.  MySQL is very friendly to PHP, the most appreciated language for web development.  MySQL supports large databases, up to 50 million rows or more in a table. The default file size limit for a table is 4GB, but you can increase this (if your operating system can handle it) to a theoretical limit of 8 million terabytes (TB).  MySQL is customizable. The open-source GPL license allows programmers to modify the MySQL software to fit their own specific environments.
  10. MySQL Commands Create & Show database: Use database: Create table:
  11. MySQL Commands Show table list: Show table structure: Insert values in a table: Shows all data of a table:
  12. MySQL Commands We have already created a table to the name of student to show the ALTER and SELECT operation of MySQL database. The table is :- Add address column into student table. Drop address column from student table. Drop primary key from student table.
  13. MySQL Commands Add primary key into student table. Select all data from student table. Seelect only roll & name from student table. Select roll & name where age > 18 from student table.
  14. MySQL Commands AUTO_INCREMENT property into id field of test table. Define an initial value of id (AUTO_INCREMENT) field of test table. We have created two tables to the name of loan and borrower to show the Cartesian table operation of MySQL database and inserted some data in those tables.
  15. MySQL Commands Cartesian table operation: Shows all data from loan and borrower table where loan.loan_no is equal to borrower.loan_no (and amount > 1500). String Operation: We have created a table to the name of customer to show the String operation of MySQL database and inserted some data in the table.
  16. String Operation Find the name of all customer whose name start with ‘IBR’ Find the name of all customer whose name end with ‘him’ Find the name of all customer whose name contain ‘man’ Find the name of all customer whose name second character ‘b’ Find the name of all customer whose name start with ‘Mon’ and end with ‘man’
  17. Have you any question
Publicité