mySQL Relationships.pptx - mySQL Create Relationships In Access Creating Relationships is very graphical he SQL code to create these relationships is

mySQL Relationships.pptx - mySQL Create Relationships In...

This preview shows page 1 - 6 out of 6 pages.

mySQL Create Relationships
Image of page 1
In Access Creating Relationships is very graphical he SQL code to create these relationships is generated by MS AC
Image of page 2
In mySQL Exactly the same principle but you must write the SQL code. Assume we create a database called ‘Lettings’ using the CREATE DATABASE instruction with two related tables. CREATE DATABASE Lettings;
Image of page 3
Let’s create the ‘buildings’ table CREATE TABLE buildings ( building_no INT PRIMARY KEY AUTO_INCREMENT, building_name VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL ); All straight forward
Image of page 4
Let’s create the ‘rooms’ table CREATE TABLE buildings ( building_no INT PRIMARY KEY AUTO_INCREMENT, building_name VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL
Image of page 5
Image of page 6

You've reached the end of your free preview.

Want to read all 6 pages?

Unformatted text preview: ); CREATE TABLE rooms ( room_no INT PRIMARY KEY AUTO_INCREMENT, room_name VARCHAR(255) NOT NULL, building_no INT NOT NULL, FOREIGN KEY (building_no) REFERENCES buildings (building_no) ); Let’s Insert some Data INSERT INTO buildings(building_name,address) VALUES('ACME Headquaters','3950 North 1st Street CA 95134'), ('ACME Sales','5000 North 1st Street CA 95134'); INSERT INTO rooms(room_name,building_no) VALUES('Amazon',1), ('War Room',1), ('Office of CEO',1), ('Marketing',2), ('Showroom',2); Write some queries to ensure all is worki SELECT * FROM rooms WHERE building_no = 1 SELECT distinct building_name, address from buildings, r WHERE rooms.building_no = 2;...
View Full Document

  • Spring '14

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors