简体   繁体   中英

Query: Tables with indexing/foregeing keys/correlated data

I am currently working with a MySQL database table structure. I found a great table structure online but i am not sure how to duplicate such thing. I am new to this and I am requesting help in creating a query that will create all tables( which have correlated data(index), foreign keys, many to many relationships, etc.).

Random I was able to make a query to select all fields:

SELECT *

FROM schedule 

INNER JOIN semester 

ON schedule.semester_id = semester.id

INNER JOIN office_hours

ON office_hours.schedule_id = schedule.semester_id

INNER JOIN faculty

ON faculty.id = office_hours.faculty_id

INNER JOIN faculty_titles

ON faculty_titles.faculty_id = faculty.id

INNER JOIN faculty_education

ON faculty_education.faculty_id = faculty.id 

INNER JOIN section

ON section.faculty_id = faculty.id 

INNER JOIN class

ON class.id = section.class_id

INNER JOIN major_class_br

You find a good documentation of how to create tables in the corresponding MySQL documentation:

You can user MySQL Workbench if you want to play a little with a graphical front-end. You can download it from the link or install it from you Linux repository.

There are three section in the workbench: SQL Development, Data Modeling, and Server Administration. Choose "Create new EER Model" in the Data Modeling section and then "Add Diagramm". You can insert new Tables by drag and drop from the left bar and apply your model to your database by clicking on the Database menu entry and then "Forward Engineer...".

The table structure you linked in you querstion was created by MySQL Workbench as well. Therefore, it should be easy for you to compare it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM