Hi everyone, i am designing database for books application. I have main table Books and its child table is Chapters, chapters child table is Sections, So here is the problem, that some chapters has also divided into 3 steps chapter Name -> Part 1 -> Divisions 1 and each chapter consist on sections and sections also devided on to futher 3 steps Section -> sub Sections.

Question: How can i manage chapter's parts and divisions because it is not compulsory that each chapter has its parts and and divisions and same question is for sections becouse some sections has sub sections or some sections are not.

Below i mention the structure of the book.

Book Name:
    Chapter 1
        section 1
        section 2
    chapter2
        Part 1
            Devision 1
                Section 1
                section 2
                    sub section 2(1)
                    sub section 2(2)
            Devision 2
                section 1
                section 2
            Devision 3
                section 1
                section 2
        Part 2
            section 1
            section 2
    chapter3
        section 1
        section 2

So how can i do this in mysql ?

Book, chapter, part, devision, section and subsection should each have their own table. Records in it should point to their parent (foreign key).

You should always have a part and devision, but you can hide it from showing if there is only one child in it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.